Documentation ¶
Overview ¶
Package wotsp implements WOTSP-SHA2_256 as documented in RFC 8391 (https://datatracker.ietf.org/doc/rfc8391/).
W-OTS+ is a one-time hash-based signature scheme that is most commonly used in a larger scheme such as XMSS or SPHINCS. As a W-OTS+ private key/private seed can only be used once securely, W-OTS+ should not be used directly to create signatures in most situations. This package is thus meant primarily to be used in larger structures such as SPHINCS.
Since SHA512_256, BLAKE2b_256 and BLAKE2s_256 work out of the box, they can be used as the internal hash function as well by setting Opts.Hash to their corresponding crypto.Hash values.
Index ¶
- Constants
- func GenPublicKey(seed, pubSeed []byte, opts Opts) (pubKey []byte)
- func PublicKeyFromSig(sig, msg, pubSeed []byte, opts Opts) (pubKey []byte)
- func Sign(msg, seed, pubSeed []byte, opts Opts) (sig []byte)
- func Verify(pk, sig, msg, pubSeed []byte, opts Opts) bool
- type Address
- type Mode
- type Opts
- type Params
Constants ¶
const ( W4PublicKeyBytes = 4256 // size of public key W4SecretKeyBytes = W4SeedBytes // size of the secret key, which is the seed W4Bytes = 4256 // size of signatures W4SeedBytes = 32 // size of the secret seed W4PubSeedBytes = 32 // size of the public seed W4AddressBytes = 32 // size of the address value W16PublicKeyBytes = 2144 W16SecretKeyBytes = W16SeedBytes W16Bytes = 2144 W16SeedBytes = 32 W16PubSeedBytes = 32 W16AddressBytes = 32 W256PublicKeyBytes = 1088 W256SecretKeyBytes = W256SeedBytes W256Bytes = 1088 W256SeedBytes = 32 W256PubSeedBytes = 32 W256AddressBytes = 32 )
constants for W-OTS+ signatures for both W4, W16 and W256 modes.
const N = 32
N is a constant defined as the output length of the used hash function.
Variables ¶
This section is empty.
Functions ¶
func GenPublicKey ¶
GenPublicKey computes the public key that corresponds to the expanded seed.
func PublicKeyFromSig ¶
PublicKeyFromSig generates a public key from the given signature
Types ¶
type Address ¶
type Address struct {
// contains filtered or unexported fields
}
Address describes a hash address, i.e. where a hash is calculated. It is used to randomize each hash function call to prevent multi-target attacks on the used hash function.
func AddressFromBytes ¶
AddressFromBytes deserializes a byte slice into a new W-OTS+ address. The given byte slice must have a length of 32.
type Mode ¶
type Mode int
Mode constants specify internal parameters according to the given mode of operation. The available parameter sets include w = 4 and w = 16. The default, which is used when no explicit mode is chosen, is w = 16. This allows the default Mode to be selected by specifying wotsp.Mode(0).
See RFC 8391 for details on the different parameter sets.
const ( // W16 indicates the parameter set of W-OTS+ where w = 16. W16 is the default // mode. // // Passing W16 to Opts opts is equivalent to passing Mode(0), or not setting // the Mode at all. W16 Mode = iota // W4 indicates the parameter set of W-OTS+ where w = 4. W4 // W256 indicates the parameter set of W-OTS+ where w = 256. W256 )
type Opts ¶
type Opts struct { Mode Mode Address Address // Concurrency specifies the amount of goroutines to use for WOTS // operations. Concurrency follows the following logic for n: // n > 0: divide chains over n goroutines. // n == 0: default, use a single goroutine // n < 0: automatically determine the number of goroutines based on // runtime.NumCPU or runtime.GOMAXPROX(-1), whichever is lower. Concurrency int // Hash specifies the specific hash function to use. For a hash function to // be accepted by the implementation, it needs to have a digest of 256 bits. // // Currently, the following values are supported: // crypto.SHA256 // crypto.SHA512_256 // crypto.BLAKE2b_256 // crypto.BLAKE2s_256 // // The default (for crypto.Hash(0)) is SHA256, as per the RFC. crypto.Hash }
Opts groups the parameters required for W-OTS+ operations. It implements crypto.SignerOpts.