Changeset ead4925 for core


Ignore:
Timestamp:
Feb 4, 2019 4:58:41 PM (22 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
a756c12
Parents:
0e029f8
Message:

Data: Represent blinding secret as a SigningPrivateKey?

Location:
core/java/src/net/i2p
Files:
4 edited

Legend:

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

    r0e029f8 read4925  
    99import net.i2p.data.SigningPrivateKey;
    1010import net.i2p.data.SigningPublicKey;
    11 import net.i2p.data.SimpleDataStructure;
    1211
    1312
     
    2827     *
    2928     *  @param key must be SigType EdDSA_SHA512_Ed25519
    30      *  @param h hash of secret data, same length as this key
     29     *  @param alpha the secret data
    3130     *  @throws UnsupportedOperationException unless supported
    3231     */
    33     public static SigningPublicKey blind(SigningPublicKey key, SimpleDataStructure h) {
    34         if (key.getType() != TYPE)
     32    public static SigningPublicKey blind(SigningPublicKey key, SigningPrivateKey alpha) {
     33        if (key.getType() != TYPE && alpha.getType() != TYPE)
    3534            throw new UnsupportedOperationException();
    36         if (h.length() != key.length())
    37             throw new IllegalArgumentException();
    3835        try {
    3936            EdDSAPublicKey jk = SigUtil.toJavaEdDSAKey(key);
    40             EdDSAPublicKey bjk = EdDSABlinding.blind(jk, h.getData());
     37            EdDSAPrivateKey ajk = SigUtil.toJavaEdDSAKey(alpha);
     38            EdDSAPublicKey bjk = EdDSABlinding.blind(jk, ajk);
    4139            return SigUtil.fromJavaKey(bjk, TYPE);
    4240        } catch (GeneralSecurityException gse) {
     
    4947     *
    5048     *  @param key must be SigType EdDSA_SHA512_Ed25519
    51      *  @param h hash of secret data, same length as this key
     49     *  @param alpha the secret data
    5250     *  @throws UnsupportedOperationException unless supported
    5351     */
    54     public static SigningPrivateKey blind(SigningPrivateKey key, SimpleDataStructure h) {
    55         if (key.getType() != TYPE)
     52    public static SigningPrivateKey blind(SigningPrivateKey key, SigningPrivateKey alpha) {
     53        if (key.getType() != TYPE && alpha.getType() != TYPE)
    5654            throw new UnsupportedOperationException();
    57         if (h.length() != key.length())
    58             throw new IllegalArgumentException();
    5955        try {
    6056            EdDSAPrivateKey jk = SigUtil.toJavaEdDSAKey(key);
    61             EdDSAPrivateKey bjk = EdDSABlinding.blind(jk, h.getData());
     57            EdDSAPrivateKey ajk = SigUtil.toJavaEdDSAKey(alpha);
     58            EdDSAPrivateKey bjk = EdDSABlinding.blind(jk, ajk);
    6259            return SigUtil.fromJavaKey(bjk, TYPE);
    6360        } catch (GeneralSecurityException gse) {
     
    7067     *
    7168     *  @param key must be SigType EdDSA_SHA512_Ed25519
    72      *  @param h hash of secret data, same length as this key
     69     *  @param alpha the secret data
    7370     *  @throws UnsupportedOperationException unless supported
    7471     */
    75     public static SigningPrivateKey unblind(SigningPrivateKey key, SimpleDataStructure h) {
    76         if (key.getType() != TYPE)
     72    public static SigningPrivateKey unblind(SigningPrivateKey key, SigningPrivateKey alpha) {
     73        if (key.getType() != TYPE && alpha.getType() != TYPE)
    7774            throw new UnsupportedOperationException();
    78         if (h.length() != key.length())
    79             throw new IllegalArgumentException();
    8075        try {
    8176            EdDSAPrivateKey bjk = SigUtil.toJavaEdDSAKey(key);
    82             EdDSAPrivateKey jk = EdDSABlinding.unblind(bjk, h.getData());
     77            EdDSAPrivateKey ajk = SigUtil.toJavaEdDSAKey(alpha);
     78            EdDSAPrivateKey jk = EdDSABlinding.unblind(bjk, ajk);
    8379            return SigUtil.fromJavaKey(jk, TYPE);
    8480        } catch (GeneralSecurityException gse) {
  • core/java/src/net/i2p/crypto/eddsa/EdDSABlinding.java

    r0e029f8 read4925  
    1515     *
    1616     *  @param key must be SigType EdDSA_SHA512_Ed25519
    17      *  @param h hash of secret data, same length as this key
     17     *  @param alpha generated from hash of secret data
    1818     *  @throws UnsupportedOperationException unless supported
    1919     */
    20     public static EdDSAPublicKey blind(EdDSAPublicKey key, byte[] h) {
     20    public static EdDSAPublicKey blind(EdDSAPublicKey key, EdDSAPrivateKey alpha) {
    2121        // TODO, test only
    2222        return key;
     
    2727     *
    2828     *  @param key must be SigType EdDSA_SHA512_Ed25519
    29      *  @param h hash of secret data, same length as this key
     29     *  @param alpha generated from hash of secret data
    3030     *  @throws UnsupportedOperationException unless supported
    3131     */
    32     public static EdDSAPrivateKey blind(EdDSAPrivateKey key, byte[] h) {
     32    public static EdDSAPrivateKey blind(EdDSAPrivateKey key, EdDSAPrivateKey alpha) {
    3333        // TODO, test only
    3434        return key;
     
    3939     *
    4040     *  @param key must be SigType EdDSA_SHA512_Ed25519
    41      *  @param h hash of secret data, same length as this key
     41     *  @param alpha generated from hash of secret data
    4242     *  @throws UnsupportedOperationException unless supported
    4343     */
    44     public static EdDSAPrivateKey unblind(EdDSAPrivateKey key, byte[] h) {
     44    public static EdDSAPrivateKey unblind(EdDSAPrivateKey key, EdDSAPrivateKey alpha) {
    4545        // TODO, test only
    4646        return key;
  • core/java/src/net/i2p/data/SigningPrivateKey.java

    r0e029f8 read4925  
    9393     *  Only for SigType EdDSA_SHA512_Ed25519
    9494     *
    95      *  @param h hash of secret data, same length as this key
     95     *  @param alpha the secret data
    9696     *  @throws UnsupportedOperationException unless supported
    9797     *  @since 0.9.38
    9898     */
    99     public SigningPrivateKey blind(SimpleDataStructure h) {
    100         return Blinding.blind(this, h);
     99    public SigningPrivateKey blind(SigningPrivateKey alpha) {
     100        return Blinding.blind(this, alpha);
    101101    }
    102102
  • core/java/src/net/i2p/data/SigningPublicKey.java

    r0e029f8 read4925  
    201201     *  Only for SigType EdDSA_SHA512_Ed25519
    202202     *
    203      *  @param h hash of secret data, same length as this key
     203     *  @param alpha the secret data
    204204     *  @throws UnsupportedOperationException unless supported
    205205     *  @since 0.9.38
    206206     */
    207     public SigningPublicKey blind(SimpleDataStructure h) {
    208         return Blinding.blind(this, h);
     207    public SigningPublicKey blind(SigningPrivateKey alpha) {
     208        return Blinding.blind(this, alpha);
    209209    }
    210210
Note: See TracChangeset for help on using the changeset viewer.