Sha256: e709e108302c30357e7b829cc4233f77f5f2ad5b854e7f89455ae1121a4e03a8

Contents?: true

Size: 1.69 KB

Versions: 33

Compression:

Stored size: 1.69 KB

Contents

/**
 * EdDSA-Java by str4d
 *
 * To the extent possible under law, the person who associated CC0 with
 * EdDSA-Java has waived all copyright and related or neighboring rights
 * to EdDSA-Java.
 *
 * You should have received a copy of the CC0 legalcode along with this
 * work. If not, see <https://creativecommons.org/publicdomain/zero/1.0/>.
 *
 */
package net.i2p.crypto.eddsa.math;

/**
 * Common interface for all $(b-1)$-bit encodings of elements
 * of EdDSA finite fields.
 * @author str4d
 *
 */
public abstract class Encoding {
    protected Field f;

    public synchronized void setField(Field f) {
        if (this.f != null)
            throw new IllegalStateException("already set");
        this.f = f;
    }

    /**
     * Encode a FieldElement in its $(b-1)$-bit encoding.
     * @param x the FieldElement to encode
     * @return the $(b-1)$-bit encoding of this FieldElement.
     */
    public abstract byte[] encode(FieldElement x);

    /**
     * Decode a FieldElement from its $(b-1)$-bit encoding.
     * The highest bit is masked out.
     * @param in the $(b-1)$-bit encoding of a FieldElement.
     * @return the FieldElement represented by 'val'.
     */
    public abstract FieldElement decode(byte[] in);

    /**
     * From the Ed25519 paper:<br>
     * $x$ is negative if the $(b-1)$-bit encoding of $x$ is lexicographically larger
     * than the $(b-1)$-bit encoding of -x. If $q$ is an odd prime and the encoding
     * is the little-endian representation of $\{0, 1,\dots, q-1\}$ then the negative
     * elements of $F_q$ are $\{1, 3, 5,\dots, q-2\}$.
     * @param x the FieldElement to check
     * @return true if negative
     */
    public abstract boolean isNegative(FieldElement x);
}

Version data entries

33 entries across 29 versions & 2 rubygems

Version Path
ed25519-1.3.0 ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Encoding.java
ed25519-1.3.0-java ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Encoding.java
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/3.0.0/gems/ed25519-1.2.4/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Encoding.java
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/3.0.0/gems/ed25519-1.2.4/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Encoding.java
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/3.0.0/gems/ed25519-1.2.4/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Encoding.java
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.7.0/gems/ed25519-1.2.4/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Encoding.java
vagrant-unbundled-2.2.14.0 vendor/bundle/ruby/2.7.0/gems/ed25519-1.2.4/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Encoding.java
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.7.0/gems/ed25519-1.2.4/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Encoding.java
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.7.0/gems/ed25519-1.2.4/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Encoding.java
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.7.0/gems/ed25519-1.2.4/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Encoding.java
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/ed25519-1.2.4/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Encoding.java
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/ed25519-1.2.4/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Encoding.java
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/ed25519-1.2.4/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Encoding.java
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/ed25519-1.2.4/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Encoding.java
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/ed25519-1.2.4/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Encoding.java
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/ed25519-1.2.4/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Encoding.java
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/ed25519-1.2.4/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Encoding.java
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/ed25519-1.2.4/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Encoding.java
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/ed25519-1.2.4/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Encoding.java
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/ed25519-1.2.4/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Encoding.java