Documentation ¶
Index ¶
- func Add(d, a, b *[4]uint64, rf Reduce256)
- func Decode(d *[4]uint64, src []byte, r *[4]uint64) int
- func DecodeReduce(d *[4]uint64, src []byte, rf Reduce384)
- func Encode(b []byte, s *[4]uint64, rf Reduce256) []byte
- func Mul(d, a, b *[4]uint64, rf Reduce384)
- func Mul128x128(d *[4]uint64, a, b *[2]uint64)
- func Mul128x128trunc(d, a, b *[2]uint64)
- func Mul256x128(d *[6]uint64, a *[4]uint64, b *[2]uint64)
- func Mul256x256(d *[8]uint64, a *[4]uint64, b *[4]uint64)
- func Recode5(d *[52]byte, a *[4]uint64)
- func Recode5Small(d *[26]byte, k *[2]uint64)
- func Recode5SmallSigned(d *[26]byte, k *[2]uint64) uint64
- func Sub(d, a, b *[4]uint64, rf Reduce256, r *[4]uint64)
- func ToBytes(s *[4]uint64, rf Reduce256) [32]byte
- type Reduce256
- type Reduce384
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
Scalar addition; partial reduction function is provided (rf). The reduction function must ensure that the result fits on 255 bits.
func Decode ¶
Decode a scalar value from bytes. Modulus r is provided. Returned value:
1 decode successful, value is in range and non-zero 0 decode successful, value is zero -1 decode failed, value is out of range.
On error, output value (in d[]) is forced to zero.
func DecodeReduce ¶
Decode a scalar from bytes; the bytes are interpreted with unsigned little-endian convention into a big integer, which is reduced modulo the curve subgroup order r. All bytes from the input slice are used. If the input slice is empty, then the obtained value is 0. The reduction is applied with the provided function (rf) for reduction 384->256.
func Encode ¶
Encode a scalar into exactly 32 bytes. The scalar is reduced by invoking the provided reduction function. The bytes are appended to the provided slice. The extension is done in place if the provided slice has enough capacity. The new slice is returned.
func Mul256x128 ¶
256x128->384 multiplication.
func Mul256x256 ¶
256x256->512 multiplication.
func Recode5 ¶
Recode a scalar with 5-bit Booth encoding. Output is a sequence of small integers in the -15..+16 range such that:
a = \sum_{i=0}^{51} d[i]*2^(5*i)
Top digit d[51] is nonnegative. If the input value is less than 2^255, then the top digit can only be 0 or 1. Each output digit is encoded in a byte as sign+mantissa: the low 5 bits of the byte are the absolute value of the digit (in the 0..16 range), and the high bit of the byte is set to 1 for a negative digit, 0 otherwise. When the digit is 0, the function may encode it as -0 (0x80) or +0 (0x00) (the top digit d[51] cannot be -0, only +0).
func Recode5Small ¶
Recode a small _unsigned_ 128-bit integer with 5-bit Booth encoding. Output is 26 digits, the top digit is necessarily nonnegative (and cannot be -0).
func Recode5SmallSigned ¶
Recode a small _signed_ 128-bit integer with 5-bit Booth encoding. If the source value is negative, then what is recoded is its absolute value; the source sign is returned (1 for negative, 0 for zero or positive). Output is 26 digits, the top digit is necessarily nonnegative (and cannot be -0).