net.i2p.crypto.eddsa

## Class RedDSAEngine

- java.lang.Object
- - java.security.SignatureSpi
  - - java.security.Signature
    - - net.i2p.crypto.eddsa.EdDSAEngine
      - - net.i2p.crypto.eddsa.RedDSAEngine

-     public final class RedDSAEngine
      extends EdDSAEngine

  Signing and verification for REdDSA using SHA-512 and the Ed25519 curve. Ref: Zcash Protocol Specification, Version 2018.0-beta-33 [Overwinter+Sapling] Sections 4.1.6.1, 4.1.6.2, 5.4.6

  The EdDSA sign and verify algorithms do not interact well with the Java Signature API, as one or more update() methods must be called before sign() or verify(). Using the standard API, this implementation must copy and buffer all data passed in via update().

  This implementation offers two ways to avoid this copying, but only if all data to be signed or verified is available in a single byte array.

  Option 1:

  1. Call initSign() or initVerify() as usual.
  2. Call setParameter(ONE_SHOT_MODE)
  3. Call update(byte[]) or update(byte[], int, int) exactly once
  4. Call sign() or verify() as usual.
  5. If doing additional one-shot signs or verifies with this object, you must call setParameter(ONE_SHOT_MODE) each time

  Option 2:

  1. Call initSign() or initVerify() as usual.
  2. Call one of the signOneShot() or verifyOneShot() methods.
  3. If doing additional one-shot signs or verifies with this object, just call signOneShot() or verifyOneShot() again.

- - ### Field Summary

    - ### Fields inherited from class net.i2p.crypto.eddsa.EdDSAEngine

      `digest, ONE_SHOT_MODE, SIGNATURE_ALGORITHM`

    - ### Fields inherited from class java.security.Signature

      `SIGN, state, UNINITIALIZED, VERIFY`

    - ### Fields inherited from class java.security.SignatureSpi

      `appRandom`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RedDSAEngine()` No specific EdDSA-internal hash requested, allows any EdDSA key.
    `RedDSAEngine(MessageDigest digest)` Specific EdDSA-internal hash requested, only matching keys will be allowed.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `digestInitSign(EdDSAPrivateKey privKey)`

    - ### Methods inherited from class net.i2p.crypto.eddsa.EdDSAEngine

      `engineInitSign, engineInitVerify, engineSetParameter, engineSign, engineUpdate, engineUpdate, engineVerify, signOneShot, signOneShot, verifyOneShot, verifyOneShot, verifyOneShot, verifyOneShot`

    - ### Methods inherited from class java.security.Signature

      `clone, getAlgorithm, getInstance, getInstance, getInstance, getParameter, getParameters, getProvider, initSign, initSign, initVerify, initVerify, setParameter, setParameter, sign, sign, toString, update, update, update, update, verify, verify`

    - ### Methods inherited from class java.security.SignatureSpi

      `engineGetParameter, engineGetParameters, engineInitSign, engineSetParameter, engineSign, engineUpdate, engineVerify`

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

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

- - ### Constructor Detail

    - #### RedDSAEngine

          public RedDSAEngine()

      No specific EdDSA-internal hash requested, allows any EdDSA key.

    - #### RedDSAEngine

          public RedDSAEngine(MessageDigest digest)

      Specific EdDSA-internal hash requested, only matching keys will be allowed.
      Parameters:
        `digest` - the hash algorithm that keys must have to sign or verify.

  - ### Method Detail

    - #### digestInitSign

          protected void digestInitSign(EdDSAPrivateKey privKey)

      Overrides:
        `digestInitSign` in class `EdDSAEngine`