Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArbitraryN ¶
type ArbitraryN struct {
// contains filtered or unexported fields
}
ArbitraryN builds on one of the block permutations to make a permutation over an arbitrary range. The underlying power-of-2 permutation is iterated to find an in-range result resulting in variable runtime.
func NewNInt ¶
func NewNInt(key []byte, n int) *ArbitraryN
func (*ArbitraryN) PermuteInPlace ¶
PermuteInPlace calculates inOut's permutated value and stores it back into inOut. Returns inOut as a convenience.
func (*ArbitraryN) PermuteInt ¶
func (p *ArbitraryN) PermuteInt(in int) int
Example ¶
const n = 5
p := NewNInt([]byte("mykey"), n)
for i := range n {
fmt.Println(i, "->", p.PermuteInt(i))
}
Output: 0 -> 1 1 -> 4 2 -> 2 3 -> 0 4 -> 3
type FFX ¶
type FFX struct {
// contains filtered or unexported fields
}
FFX implements a permutation over [0, 2^lengthBits) using the FFX-A2 construction over AES. Key derivation uses HKDF, so the input key can be any length. Where needed, numbers are encoded in big-endian.
func (*FFX) PermuteInPlace ¶
PermuteInPlace calculates inOut's permutated value and stores it back into inOut. Returns inOut as a convenience.
func (*FFX) PermuteInt ¶
type FeistelSHAKE128 ¶
type FeistelSHAKE128 struct {
// contains filtered or unexported fields
}
FeistelSHAKE128 implements a variable-length block cipher to generate a key-dependent permutation over [0, 2^n - 1]. It uses a Feistel construction with SHAKE128 as the PRF for the round function. This allows for arbitrarily-long inputs/outputs.
func NewPowerOf2 ¶
func NewPowerOf2(key []byte, lengthBits int) *FeistelSHAKE128
func (*FeistelSHAKE128) PermuteInPlace ¶
PermuteInPlace calculates inOut's permutated value and stores it back into inOut. Returns inOut as a convenience.
func (*FeistelSHAKE128) PermuteInt ¶
func (p *FeistelSHAKE128) PermuteInt(in int) int