dilithium

package
v0.0.0-...-b7eb19c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2023 License: MIT Imports: 7 Imported by: 84

Documentation

Index

Constants

View Source
const (
	CryptoPublicKeyBytes = SeedBytes + K*PolyT1PackedBytes
	CryptoSecretKeyBytes = 3*SeedBytes + L*PolyETAPackedBytes + K*PolyETAPackedBytes + K*PolyT0PackedBytes
	// CryptoBytes is the signature size in bytes
	CryptoBytes = SeedBytes + L*PolyZPackedBytes + PolyVecHPackedBytes

	Shake128Rate        = 168
	Shake256Rate        = 136
	Stream128BlockBytes = Shake128Rate
	Stream256BlockBytes = Shake256Rate

	PolyUniformNBlocks       = (768 + Stream128BlockBytes - 1) / Stream128BlockBytes
	PolyUniformETANBlocks    = (136 + Stream256BlockBytes - 1) / Stream256BlockBytes
	PolyUniformGamma1NBlocks = (PolyZPackedBytes + Stream256BlockBytes - 1) / Stream256BlockBytes

	SeedBytes = 32
	CRHBytes  = 64 // hash of public key
	N         = 256
	Q         = 8380417
	QInv      = 58728449 // -q^(-1) mod 2^32
	D         = 13

	K      = 8
	L      = 7
	ETA    = 2
	TAU    = 60
	BETA   = 120
	GAMMA1 = 1 << 19
	GAMMA2 = (Q - 1) / 32
	OMEGA  = 75

	// Polynomial sizes
	PolyT1PackedBytes   = 320
	PolyT0PackedBytes   = 416
	PolyETAPackedBytes  = 96
	PolyZPackedBytes    = 640
	PolyVecHPackedBytes = OMEGA + K
	PolyW1PackedBytes   = 128
)

Variables

This section is empty.

Functions

func ExtractMessage

func ExtractMessage(signatureMessage []uint8) []uint8

ExtractMessage extracts message from Signature attached with message.

func ExtractSignature

func ExtractSignature(signatureMessage []uint8) []uint8

ExtractSignature extracts signature from Signature attached with message.

func GetDilithiumAddressFromPK

func GetDilithiumAddressFromPK(pk [CryptoPublicKeyBytes]uint8) [common.AddressSize]uint8

func GetDilithiumDescriptor

func GetDilithiumDescriptor() uint8

func IsValidDilithiumAddress

func IsValidDilithiumAddress(address [common.AddressSize]uint8) bool

func Open

func Open(signatureMessage []uint8, pk *[CryptoPublicKeyBytes]uint8) []uint8

Open the sealed message m. Returns the original message sealed with signature. In case the signature is invalid, nil is returned.

func Verify

func Verify(message []uint8, signature [CryptoBytes]uint8, pk *[CryptoPublicKeyBytes]uint8) bool

Types

type Dilithium

type Dilithium struct {
	// contains filtered or unexported fields
}

func New

func New() (*Dilithium, error)

func NewDilithiumFromHexSeed

func NewDilithiumFromHexSeed(hexSeed string) (*Dilithium, error)

func NewDilithiumFromMnemonic

func NewDilithiumFromMnemonic(mnemonic string) (*Dilithium, error)

func NewDilithiumFromSeed

func NewDilithiumFromSeed(seed [common.SeedSize]uint8) (*Dilithium, error)

func (*Dilithium) GetAddress

func (d *Dilithium) GetAddress() [common.AddressSize]uint8

func (*Dilithium) GetHexSeed

func (d *Dilithium) GetHexSeed() string

func (*Dilithium) GetMnemonic

func (d *Dilithium) GetMnemonic() string

func (*Dilithium) GetPK

func (d *Dilithium) GetPK() [CryptoPublicKeyBytes]uint8

func (*Dilithium) GetSK

func (d *Dilithium) GetSK() [CryptoSecretKeyBytes]uint8

func (*Dilithium) GetSeed

func (d *Dilithium) GetSeed() [common.SeedSize]uint8

func (*Dilithium) Seal

func (d *Dilithium) Seal(message []uint8) ([]uint8, error)

Seal the message, returns signature attached with message.

func (*Dilithium) Sign

func (d *Dilithium) Sign(message []uint8) ([CryptoBytes]uint8, error)

Sign the message, and return a detached signature. Detached signatures are variable sized, but never larger than SIG_SIZE_PACKED.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL