Documentation
¶
Overview ¶
Package hppk implements the Hierarchical Polynomial Public Key (HPPK) cryptosystem.
HPPK introduces a novel Homomorphic Polynomial Public Key for Key Encapsulation Mechanism (KEM) and Digital Signatures (DS). By exploiting the inherent partial homomorphic properties of the modular multiplicative permutations, HPPK offers a robust symmetric encryption mechanism for asymmetric cryptography, independent of NP-hard problems. The seamless integration of KEM and DS within HPPK results in compact key sizes, cipher sizes, and signature sizes, demonstrating exceptional performance across various cryptographic operations
Index ¶
- Constants
- func VerifySignature(sig *Signature, digest []byte, pub *PublicKey) bool
- type KEM
- type PrivateKey
- func (priv *PrivateKey) Decrypt(kem *KEM) (secret *big.Int, err error)
- func (priv *PrivateKey) MarshalBinary() ([]byte, error)
- func (priv *PrivateKey) Order() int
- func (priv *PrivateKey) Public() *PublicKey
- func (priv *PrivateKey) Sign(digest []byte) (sign *Signature, err error)
- func (priv *PrivateKey) UnmarshalBinary(data []byte) error
- type PublicKey
- type Signature
Constants ¶
const ( ERR_MSG_ORDER = "order must be at least 5" ERR_MSG_NULL_ENCRYPTION = "encrypted values cannot be null" ERR_MSG_DATA_EXCEEDED = "the secret to encrypt is not in the GF(p)" ERR_MSG_INVALID_PUBKEY = "public key is invalid" ERR_MSG_INVALID_KEM = "invalid kem value" ERR_MSG_INVALID_PRIME = "invalid prime number" )
Error messages for various conditions.
const DefaultPrime = "" /* 515-byte string literal not displayed */
DefaultPrime is a large prime number used in cryptographic operations.
const MULTIVARIATE = 5 // default variants
Variables ¶
This section is empty.
Functions ¶
Types ¶
type PrivateKey ¶
type PrivateKey struct {
R1, S1 *big.Int // r1 and s1 are coprimes
R2, S2 *big.Int // r2 and s2 are coprimes
F0, F1 *big.Int // f(x) = f1x + f0
H0, H1 *big.Int // h(x) = h1x + h0
PublicKey // Embedding PublicKey structure
}
PrivateKey represents a private key in the HPPK protocol.
func GenerateKey ¶
func GenerateKey(order int) (*PrivateKey, error)
GenerateKey generates a new HPPK private key with the given order and default prime number.
func GenerateKeyWithPrime ¶ added in v1.0.9
func GenerateKeyWithPrime(order int, strPrime string) (*PrivateKey, error)
GenerateKey generates a new HPPK private key with the given order and custom prime number.
func (*PrivateKey) Decrypt ¶
func (priv *PrivateKey) Decrypt(kem *KEM) (secret *big.Int, err error)
Decrypt decrypts the encrypted values P and Q using the private key.
func (*PrivateKey) MarshalBinary ¶ added in v1.1.2
func (priv *PrivateKey) MarshalBinary() ([]byte, error)
MarshalBinary encodes the private key along with its embedded public key.
func (*PrivateKey) Order ¶ added in v1.0.6
func (priv *PrivateKey) Order() int
Order returns the polynomial order of the private key.
func (*PrivateKey) Public ¶ added in v1.0.4
func (priv *PrivateKey) Public() *PublicKey
Public returns the public key of the private key.
func (*PrivateKey) Sign ¶
func (priv *PrivateKey) Sign(digest []byte) (sign *Signature, err error)
Sign the message digest, returning a signature.
func (*PrivateKey) UnmarshalBinary ¶ added in v1.1.2
func (priv *PrivateKey) UnmarshalBinary(data []byte) error
UnmarshalBinary restores the private key values from MarshalBinary output.
type PublicKey ¶
type PublicKey struct {
Prime *big.Int // Prime number used for cryptographic operations
P []*big.Int // Coefficients of the polynomial P(x)
Q []*big.Int // Coefficients of the polynomial Q(x)
}
PublicKey represents a public key in the HPPK protocol.
func (*PublicKey) MarshalBinary ¶ added in v1.1.2
MarshalBinary encodes the public key using the custom HPPK binary layout.
func (*PublicKey) UnmarshalBinary ¶ added in v1.1.2
UnmarshalBinary populates the public key from MarshalBinary output.
type Signature ¶
type Signature struct {
Beta *big.Int // a randomly choosen number from Fp
F, H *big.Int // F & H is calculated from the private key
S1Verify, S2Verify *big.Int // S1Verify := beta * s1 mod p, S2Verify := beta * s2 mod p
U, V []*big.Int // U = ⌊ R*P /S1 ⌋, V = ⌊ R*Q /S2 ⌋
K int // R = 2^K
}
Signature represents a digital signature in the HPPK protocol.