net.i2p.crypto

## Class Blinding

- java.lang.Object
- - net.i2p.crypto.Blinding

-     public final class Blinding
      extends Object

  Utilities for Blinding EdDSA keys. PRELIMINARY - Subject to change - see proposal 123

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static SigningPrivateKey` | `blind(SigningPrivateKey key, SigningPrivateKey alpha)` Only for SigTypes EdDSA_SHA512_Ed25519 and RedDSA_SHA512_Ed25519.
    `static SigningPublicKey` | `blind(SigningPublicKey key, SigningPrivateKey alpha)` Only for SigTypes EdDSA_SHA512_Ed25519 and RedDSA_SHA512_Ed25519.
    `static BlindData` | `decode(I2PAppContext ctx, byte[] b)` Decode a new-format b32 address.
    `static BlindData` | `decode(I2PAppContext ctx, String address)` Decode a new-format b32 address.
    `static String` | `encode(SigningPublicKey key)` Encode a public key as a new-format b32 address.
    `static String` | `encode(SigningPublicKey key, boolean requireSecret, boolean requireAuth)` Encode a public key as a new-format b32 address.
    `static SigningPrivateKey` | `generateAlpha(I2PAppContext ctx, SigningPublicKey destspk, String secret)` Generate alpha for current time.
    `static SigningPrivateKey` | `generateAlpha(I2PAppContext ctx, SigningPublicKey destspk, String secret, long now)` Generate alpha for the given time.
    `static SigType` | `getDefaultBlindedType(SigType unblindedType)` What's the default blinded type for a given unblinded type?
    `static void` | `main(String[] args)` Command-line tool for encoding/decoding b32 addresses.
    `static SigningPrivateKey` | `unblind(SigningPrivateKey key, SigningPrivateKey alpha)` Only for SigType EdDSA_SHA512_Ed25519.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### blind

          public static SigningPrivateKey blind(SigningPrivateKey key,
                                                SigningPrivateKey alpha)

      Only for SigTypes EdDSA_SHA512_Ed25519 and RedDSA_SHA512_Ed25519.
      Parameters:
        `key` - must be SigType EdDSA_SHA512_Ed25519 or RedDSA_SHA512_Ed25519
        `alpha` - must be SigType RedDSA_SHA512_Ed25519
      Returns:
        SigType RedDSA_SHA512_Ed25519
      Throws:
        `IllegalArgumentException` - on bad inputs or unsupported SigTypes

    - #### blind

          public static SigningPublicKey blind(SigningPublicKey key,
                                               SigningPrivateKey alpha)

      Only for SigTypes EdDSA_SHA512_Ed25519 and RedDSA_SHA512_Ed25519.
      Parameters:
        `key` - must be SigType EdDSA_SHA512_Ed25519 or RedDSA_SHA512_Ed25519
        `alpha` - must be SigType RedDSA_SHA512_Ed25519
      Returns:
        SigType RedDSA_SHA512_Ed25519
      Throws:
        `IllegalArgumentException` - on bad inputs or unsupported SigTypes

    - #### decode

          public static BlindData decode(I2PAppContext ctx,
                                         byte[] b)
                                  throws IllegalArgumentException

      Decode a new-format b32 address. See proposal 149. NOTE: Not for external use, use decode(String)
      Parameters:
        `ctx` - the application context
        `b` - 35+ bytes
      Returns:
        BlindData structure, use getUnblindedPubKey() for the result
      Throws:
        `IllegalArgumentException` - on bad inputs or unsupported SigTypes

    - #### decode

          public static BlindData decode(I2PAppContext ctx,
                                         String address)
                                  throws IllegalArgumentException

      Decode a new-format b32 address. See proposal 149.
      Parameters:
        `ctx` - the application context
        `address` - ending with ".b32.i2p"
      Returns:
        BlindData structure, use getUnblindedPubKey() for the result
      Throws:
        `IllegalArgumentException` - on bad inputs or unsupported SigTypes

    - #### encode

          public static String encode(SigningPublicKey key)
                               throws IllegalArgumentException

      Encode a public key as a new-format b32 address. See proposal 149.
      Parameters:
        `key` - the signing public key to encode
      Returns:
        (56 chars).b32.i2p
      Throws:
        `IllegalArgumentException` - on bad inputs or unsupported SigTypes

    - #### encode

          public static String encode(SigningPublicKey key,
                                      boolean requireSecret,
                                      boolean requireAuth)
                               throws IllegalArgumentException

      Encode a public key as a new-format b32 address. See proposal 149.
      Parameters:
        `key` - the signing public key to encode
        `requireSecret` - whether a secret is required
        `requireAuth` - whether authentication is required
      Returns:
        (56 chars).b32.i2p
      Throws:
        `IllegalArgumentException` - on bad inputs or unsupported SigTypes

    - #### generateAlpha

          public static SigningPrivateKey generateAlpha(I2PAppContext ctx,
                                                        SigningPublicKey destspk,
                                                        String secret)

      Generate alpha for current time. Only for SigType EdDSA_SHA512_Ed25519.
      Parameters:
        `ctx` - the application context
        `destspk` - must be SigType EdDSA_SHA512_Ed25519
        `secret` - may be null or zero-length
      Returns:
        SigType RedDSA_SHA512_Ed25519
      Throws:
        `IllegalArgumentException` - on bad inputs or unsupported SigTypes

    - #### generateAlpha

          public static SigningPrivateKey generateAlpha(I2PAppContext ctx,
                                                        SigningPublicKey destspk,
                                                        String secret,
                                                        long now)

      Generate alpha for the given time. Only for SigType EdDSA_SHA512_Ed25519 or RedDSA_SHA512_Ed25519.
      Parameters:
        `ctx` - the application context
        `destspk` - must be SigType EdDSA_SHA512_Ed25519 or RedDSA_SHA512_Ed25519
        `secret` - may be null or zero-length
        `now` - the time in milliseconds for which to generate alpha
      Returns:
        SigType RedDSA_SHA512_Ed25519
      Throws:
        `IllegalArgumentException` - on bad inputs or unsupported SigTypes

    - #### getDefaultBlindedType

          public static SigType getDefaultBlindedType(SigType unblindedType)

      What's the default blinded type for a given unblinded type?
      Parameters:
        `unblindedType` - the unblinded signature type
      Returns:
        non-null

    - #### main

          public static void main(String[] args)
                           throws Exception

      Command-line tool for encoding/decoding b32 addresses.
      Parameters:
        `args` - command-line arguments
      Throws:
        `Exception` - on error

    - #### unblind

          public static SigningPrivateKey unblind(SigningPrivateKey key,
                                                  SigningPrivateKey alpha)

      Only for SigType EdDSA_SHA512_Ed25519.
      Parameters:
        `key` - must be SigType RedDSA_SHA512_Ed25519
        `alpha` - must be SigType RedDSA_SHA512_Ed25519
      Returns:
        SigType EdDSA_SHA512_Ed25519
      Throws:
        `IllegalArgumentException` - on bad inputs or unsupported SigTypes