Top Description Fields Constructors Methods
org.bouncycastle.pqc.crypto.sphincs

public Class SPHINCS256Signer

extends Object
implements MessageSigner
Class Inheritance
All Implemented Interfaces
org.bouncycastle.pqc.crypto.MessageSigner
Imports
org.bouncycastle.crypto.CipherParameters, .Digest, org.bouncycastle.crypto.params.ParametersWithRandom, org.bouncycastle.pqc.crypto.MessageSigner, org.bouncycastle.util.Pack

SPHINCS-256 signer.

This implementation is heavily based on the reference implementation in SUPERCOP, the main difference being the digests used for message hashing and tree construction are now configurable (within limits...) and that the implementation produces detached signatures.

The SPHINCS reference implementation is public domain, as per the statement in the second last paragraph of section 1 in https://eprint.iacr.org/2014/795.pdf

Field Summary

Modifier and TypeField and Description
private final HashFunctions
private byte[]

Constructor Summary

AccessConstructor and Description
public
SPHINCS256Signer(Digest
the "n-digest" must produce 32 bytes of output - used for tree construction.
nDigest
,
Digest
the "2n-digest" must produce 64 bytes of output - used for initial message/key/seed hashing.
twoNDigest
)

Base constructor.

Method Summary

Modifier and TypeMethod and Description
pack-priv static void
compute_authpath_wots(HashFunctions hs, byte[] root, byte[] authpath, int authOff, Tree.leafaddr a, byte[] sk, byte[] masks, int height)

pack-priv byte[]
crypto_sign(HashFunctions hs, byte[] m, byte[] sk)

public byte[]
generateSignature(byte[]
the message to be signed.
message
)

Implements org.bouncycastle.pqc.crypto.MessageSigner.generateSignature.

sign the passed in message (usually the output of a hash function).
public void
init(boolean
true if we are generating a signature, false otherwise.
forSigning
,
CipherParameters
key parameters for signature generation.
param
)

Implements org.bouncycastle.pqc.crypto.MessageSigner.init.

initialise the signer for signature generation or signature verification.
pack-priv static void
validate_authpath(HashFunctions hs, byte[] root, byte[] leaf, int leafidx, byte[] authpath, int auOff, byte[] masks, int height)

pack-priv boolean
verify(HashFunctions hs, byte[] m, byte[] sm, byte[] pk)

public boolean
verifySignature(byte[]
the message that was supposed to have been signed.
message
,
byte[]
the signature of the message
signature
)

Implements org.bouncycastle.pqc.crypto.MessageSigner.verifySignature.

verify the message message against the signature value.
private void
zerobytes(byte[] tsk, int off, int cryptoSecretkeybytes)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

hashFunctionsback to summary
private final HashFunctions hashFunctions
keyDataback to summary
private byte[] keyData

Constructor Detail

SPHINCS256Signerback to summary
public SPHINCS256Signer(Digest nDigest, Digest twoNDigest)

Base constructor.

Parameters
nDigest:Digest

the "n-digest" must produce 32 bytes of output - used for tree construction.

twoNDigest:Digest

the "2n-digest" must produce 64 bytes of output - used for initial message/key/seed hashing.

Method Detail

compute_authpath_wotsback to summary
pack-priv static void compute_authpath_wots(HashFunctions hs, byte[] root, byte[] authpath, int authOff, Tree.leafaddr a, byte[] sk, byte[] masks, int height)
crypto_signback to summary
pack-priv byte[] crypto_sign(HashFunctions hs, byte[] m, byte[] sk)
generateSignatureback to summary
public byte[] generateSignature(byte[] message)

Implements org.bouncycastle.pqc.crypto.MessageSigner.generateSignature.

Doc from org.bouncycastle.pqc.crypto.MessageSigner.generateSignature.

sign the passed in message (usually the output of a hash function).

Parameters
message:byte[]

the message to be signed.

Returns:byte[]

the signature of the message

initback to summary
public void init(boolean forSigning, CipherParameters param)

Implements org.bouncycastle.pqc.crypto.MessageSigner.init.

Doc from org.bouncycastle.pqc.crypto.MessageSigner.init.

initialise the signer for signature generation or signature verification.

Parameters
forSigning:boolean

true if we are generating a signature, false otherwise.

param:CipherParameters

key parameters for signature generation.

validate_authpathback to summary
pack-priv static void validate_authpath(HashFunctions hs, byte[] root, byte[] leaf, int leafidx, byte[] authpath, int auOff, byte[] masks, int height)
verifyback to summary
pack-priv boolean verify(HashFunctions hs, byte[] m, byte[] sm, byte[] pk)
verifySignatureback to summary
public boolean verifySignature(byte[] message, byte[] signature)

Implements org.bouncycastle.pqc.crypto.MessageSigner.verifySignature.

Doc from org.bouncycastle.pqc.crypto.MessageSigner.verifySignature.

verify the message message against the signature value.

Parameters
message:byte[]

the message that was supposed to have been signed.

signature:byte[]

the signature of the message

zerobytesback to summary
private void zerobytes(byte[] tsk, int off, int cryptoSecretkeybytes)