Documentation
¶
Overview ¶
Package egrw implements the Expander Graph Random Walk problem for kMOSAIC.
Index ¶
- Constants
- func ApplyGenerator(element kmosaic.SL2Element, genIdx, p int) kmosaic.SL2Element
- func ApplyWalk(start kmosaic.SL2Element, walk []int, p int) kmosaic.SL2Element
- func BytesToSL2(data []byte) kmosaic.SL2Element
- func Decrypt(ct *kmosaic.EGRWCiphertext, sk kmosaic.EGRWSecretKey, pk kmosaic.EGRWPublicKey, ...) []byte
- func DeserializePublicKey(data []byte) (*kmosaic.EGRWPublicKey, error)
- func Encrypt(pk kmosaic.EGRWPublicKey, message []byte, params kmosaic.EGRWParams, ...) (*kmosaic.EGRWCiphertext, error)
- func GetGenerators(p int) []kmosaic.SL2Element
- func KeyGen(params kmosaic.EGRWParams, seed []byte) (*kmosaic.EGRWKeyPair, error)
- func ModInverse(a, p int) (int, error)
- func SL2Inverse(m kmosaic.SL2Element, p int) kmosaic.SL2Element
- func SL2Multiply(m1, m2 kmosaic.SL2Element, p int) kmosaic.SL2Element
- func SL2ToBytes(m kmosaic.SL2Element) []byte
- func SerializePublicKey(pk kmosaic.EGRWPublicKey) []byte
Constants ¶
const ( DomainStart = "kmosaic-egrw-start-v1" DomainWalk = "kmosaic-egrw-walk-v1" DomainEncrypt = "kmosaic-egrw-encrypt-v1" DomainMask = "kmosaic-egrw-mask-v1" )
Variables ¶
This section is empty.
Functions ¶
func ApplyGenerator ¶
func ApplyGenerator(element kmosaic.SL2Element, genIdx, p int) kmosaic.SL2Element
ApplyGenerator multiplies an element by one of the generators. genIdx is an index into the generator list returned by GetGenerators.
func ApplyWalk ¶
func ApplyWalk(start kmosaic.SL2Element, walk []int, p int) kmosaic.SL2Element
ApplyWalk applies a sequence of generator multiplications starting from 'start'. The walk is defined by a sequence of generator indices.
func BytesToSL2 ¶
func BytesToSL2(data []byte) kmosaic.SL2Element
BytesToSL2 deserializes a 16-byte slice to an SL(2, Z_p) element. Panics if data is less than 16 bytes; callers must validate input length.
func Decrypt ¶
func Decrypt(ct *kmosaic.EGRWCiphertext, sk kmosaic.EGRWSecretKey, pk kmosaic.EGRWPublicKey, params kmosaic.EGRWParams) []byte
Decrypt decrypts an EGRW ciphertext
func DeserializePublicKey ¶ added in v1.0.1
func DeserializePublicKey(data []byte) (*kmosaic.EGRWPublicKey, error)
DeserializePublicKey deserializes EGRW public key
func Encrypt ¶
func Encrypt(pk kmosaic.EGRWPublicKey, message []byte, params kmosaic.EGRWParams, randomness []byte) (*kmosaic.EGRWCiphertext, error)
Encrypt encrypts a message fragment using EGRW
func GetGenerators ¶
func GetGenerators(p int) []kmosaic.SL2Element
GetGenerators returns the standard generating set for SL(2, Z_p). The generators are S = [[0, -1], [1, 0]] and T = [[1, 1], [0, 1]], along with their inverses. The results are cached to avoid recomputation.
func KeyGen ¶
func KeyGen(params kmosaic.EGRWParams, seed []byte) (*kmosaic.EGRWKeyPair, error)
KeyGen generates EGRW key pair
func ModInverse ¶
ModInverse computes the modular multiplicative inverse a^(-1) mod p. It uses the extended Euclidean algorithm. Returns an error if a is 0.
func SL2Inverse ¶
func SL2Inverse(m kmosaic.SL2Element, p int) kmosaic.SL2Element
SL2Inverse computes the inverse of an SL(2, Z_p) element. For a matrix [[A, B], [C, D]] with determinant 1, the inverse is [[D, -B], [-C, A]].
func SL2Multiply ¶
func SL2Multiply(m1, m2 kmosaic.SL2Element, p int) kmosaic.SL2Element
SL2Multiply multiplies two SL(2, Z_p) elements. The result is (m1 * m2) mod p.
func SL2ToBytes ¶
func SL2ToBytes(m kmosaic.SL2Element) []byte
SL2ToBytes serializes an SL(2, Z_p) element to a 16-byte slice. Each component (A, B, C, D) is stored as a 4-byte little-endian integer.
func SerializePublicKey ¶
func SerializePublicKey(pk kmosaic.EGRWPublicKey) []byte
SerializePublicKey serializes EGRW public key
Types ¶
This section is empty.