Changeset 1e375c6d


Ignore:
Timestamp:
Oct 2, 2016 3:42:07 PM (4 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
124c2b5
Parents:
cc4f63b
Message:

Crypto: EdDSA add private key spec constructor for hash
javadocs

Location:
core/java/src/net/i2p/crypto/eddsa
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/crypto/eddsa/EdDSAPrivateKey.java

    rcc4f63b r1e375c6d  
    9090     *  This will hopefully be clarified in the next draft.
    9191     *  But sun.security.pkcs.PKCS8Key expects them so we must include them for keytool to work.
     92     *
     93     *  This encodes the seed. It will return null if constructed from
     94     *  a spec which was directly constructed from H, in which case seed is null.
    9295     *
    9396     *  @return 49 bytes for Ed25519, null for other curves
     
    175178    }
    176179
     180    /**
     181     *  @return will be null if constructed from a spec which was
     182     *          directly constructed from H
     183     */
    177184    public byte[] getSeed() {
    178185        return seed;
    179186    }
    180187
     188    /**
     189     *  @return the hash of the seed
     190     */
    181191    public byte[] getH() {
    182192        return h;
    183193    }
    184194
     195    /**
     196     *  @return the private key
     197     */
    185198    public byte[] geta() {
    186199        return a;
    187200    }
    188201
     202    /**
     203     *  @return the public key
     204     */
    189205    public GroupElement getA() {
    190206        return A;
    191207    }
    192208
     209    /**
     210     *  @return the public key
     211     */
    193212    public byte[] getAbyte() {
    194213        return Abyte;
  • core/java/src/net/i2p/crypto/eddsa/spec/EdDSAParameterSpec.java

    rcc4f63b r1e375c6d  
    5757    }
    5858
     59    /**
     60     *  @return the base (generator)
     61     */
    5962    public GroupElement getB() {
    6063        return B;
  • core/java/src/net/i2p/crypto/eddsa/spec/EdDSAPrivateKeySpec.java

    rcc4f63b r1e375c6d  
    5252    }
    5353
     54    /**
     55     *  Initialize directly from the hash.
     56     *  getSeed() will return null if this constructor is used.
     57     *
     58     *  @param h the private key
     59     *  @since 0.9.27 (GitHub issue #17)
     60     */
     61    public EdDSAPrivateKeySpec(EdDSAParameterSpec spec, byte[] h) {
     62        this.seed = null;
     63        this.h = h;
     64        this.spec = spec;
     65        int b = spec.getCurve().getField().getb();
     66
     67        h[0] &= 248;
     68        h[(b/8)-1] &= 63;
     69        h[(b/8)-1] |= 64;
     70        a = Arrays.copyOfRange(h, 0, b/8);
     71
     72        A = spec.getB().scalarMultiply(a);
     73    }
     74
    5475    public EdDSAPrivateKeySpec(byte[] seed, byte[] h, byte[] a, GroupElement A, EdDSAParameterSpec spec) {
    5576        this.seed = seed;
     
    6081    }
    6182
     83    /**
     84     *  @return will be null if constructed directly from the private key
     85     */
    6286    public byte[] getSeed() {
    6387        return seed;
    6488    }
    6589
     90    /**
     91     *  @return the hash
     92     */
    6693    public byte[] getH() {
    6794        return h;
    6895    }
    6996
     97    /**
     98     *  @return the private key
     99     */
    70100    public byte[] geta() {
    71101        return a;
    72102    }
    73103
     104    /**
     105     *  @return the public key
     106     */
    74107    public GroupElement getA() {
    75108        return A;
Note: See TracChangeset for help on using the changeset viewer.