core/crypto/ristretto255
ristretto255
Types
2Group_Element
Group_Element :: struct {
// WARNING: While the internal representation is an Edwards25519
// group element, this is not guaranteed to always be the case,
// and your code *WILL* break if you mess with `_p`.
_p: grp.Group_Element,
_is_initialized: bool,
}SourceGroup_Element is a ristretto255 group element. The zero-initialized value is invalid.
Scalar
Scalar :: ScalarSourceScalar is a ristretto255 scalar. The zero-initialized value is valid, and represents 0.
Constants
4ELEMENT_SIZE
ELEMENT_SIZE :: 32SourceELEMENT_SIZE is the size of a byte-encoded ristretto255 group element.
SCALAR_SIZE
SCALAR_SIZE :: 32SourceSCALAR_SIZE is the size of a byte-encoded ristretto255 scalar.
WIDE_ELEMENT_SIZE
WIDE_ELEMENT_SIZE :: 64SourceWIDE_ELEMENT_SIZE is the side of a wide byte-encoded ristretto255 group element.
WIDE_SCALAR_SIZE
WIDE_SCALAR_SIZE :: 64SourceWIDE_SCALAR_SIZE is the size of a wide byte-encoded ristretto255 scalar.
Procedures
32ge_add
ge_add :: proc(ge: ^Group_Element, a: ^Group_Element, b: ^Group_Element)Sourcege_add sets ge = a + b.
ge_bytes
ge_bytes :: proc(ge: ^Group_Element, dst: []u8)Sourcege_bytes sets dst to the canonical encoding of ge.
ge_clear
ge_clear :: proc(ge: ^Group_Element)Sourcege_clear clears ge to the uninitialized state.
ge_cond_assign
ge_cond_assign :: proc(ge: ^Group_Element, a: ^Group_Element, ctrl: int)Sourcege_cond_assign sets ge = ge if and only if (⟺) ctrl == 0 and ge = a if and only if (⟺) ctrl == 1. Behavior for all other values of ctrl are undefined,
ge_cond_negate
ge_cond_negate :: proc(ge: ^Group_Element, a: ^Group_Element, ctrl: int)Sourcege_cond_negate sets ge = a if and only if (⟺) ctrl == 0 and ge = -a if and only if (⟺) ctrl == 1. Behavior for all other values of ctrl are undefined,
ge_cond_select
ge_cond_select :: proc(ge: ^Group_Element, a: ^Group_Element, b: ^Group_Element, ctrl: int)Sourcege_cond_select sets ge = a if and only if (⟺) ctrl == 0 and ge = b if and only if (⟺) ctrl == 1. Behavior for all other values of ctrl are undefined,
ge_double
ge_double :: proc(ge: ^Group_Element, a: ^Group_Element)Sourcege_double sets ge = a + a.
ge_double_scalarmult_generator_vartime
ge_double_scalarmult_generator_vartime :: proc(ge: ^Group_Element, a: ^Scalar, A: ^Group_Element, b: ^Scalar)Sourcege_double_scalarmult_generator_vartime sets ge = A * a + G * b in variable time.
ge_equal
ge_equal :: proc(a: ^Group_Element, b: ^Group_Element) -> (int)Sourcege_equal returns 1 if and only if (⟺) a == b, and 0 otherwise.
ge_generator
ge_generator :: proc(ge: ^Group_Element)Sourcege_generator sets ge to the group generator.
ge_identity
ge_identity :: proc(ge: ^Group_Element)Sourcege_identity sets ge to the identity (neutral) element.
ge_is_identity
ge_is_identity :: proc(ge: ^Group_Element) -> (int)Sourcege_is_identity returns 1 if and only if (⟺) ge is the identity element, and 0 otherwise.
ge_negate
ge_negate :: proc(ge: ^Group_Element, a: ^Group_Element)Sourcege_negate sets ge = -a.
ge_scalarmult
ge_scalarmult :: proc(ge: ^Group_Element, A: ^Group_Element, sc: ^Scalar)Sourcege_scalarmult sets ge = A * sc.
ge_scalarmult_generator
ge_scalarmult_generator :: proc(ge: ^Group_Element, sc: ^Scalar)Sourcege_scalarmult_generator sets ge = G * sc
ge_scalarmult_vartime
ge_scalarmult_vartime :: proc(ge: ^Group_Element, A: ^Group_Element, sc: ^Scalar)Sourcege_scalarmult_vartime sets ge = A * sc in variable time.
ge_set
ge_set :: proc(ge: ^Group_Element, a: ^Group_Element)Sourcege_set sets ge = a.
ge_set_bytes
ge_set_bytes :: proc(ge: ^Group_Element, b: []u8) -> (bool)Sourcege_set_bytes sets ge to the result of decoding b as a ristretto255 group element, and returns true on success.
ge_set_wide_bytes
ge_set_wide_bytes :: proc(ge: ^Group_Element, b: []u8)Sourcege_set_wide_bytes sets ge to the result of deriving a ristretto255 group element, from a wide (512-bit) byte string.
sc_add
sc_add :: proc(sc: ^Scalar, a: ^Scalar, b: ^Scalar)Sourcesc_add sets sc = a + b.
sc_bytes
sc_bytes :: proc(sc: ^Scalar, dst: []u8)Sourcesc_bytes sets dst to the canonical encoding of sc.
sc_clear
sc_clear :: proc(sc: ^Scalar)Sourcesc_clear clears sc to the uninitialized state.
sc_cond_assign
sc_cond_assign :: proc(sc: ^Scalar, a: ^Scalar, ctrl: int)Sourcesc_cond_assign sets sc = sc if and only if (⟺) ctrl == 0 and sc = a if and only if (⟺) ctrl == 1. Behavior for all other values of ctrl are undefined,
sc_equal
sc_equal :: proc(a: ^Scalar, b: ^Scalar) -> (int)Sourcesc_equal returns 1 if and only if (⟺) a == b, and 0 otherwise.
sc_mul
sc_mul :: proc(sc: ^Scalar, a: ^Scalar, b: ^Scalar)Sourcesc_mul sets sc = a * b.
sc_negate
sc_negate :: proc(sc: ^Scalar, a: ^Scalar)Sourcesc_negate sets sc = -a.
sc_set
sc_set :: proc(sc: ^Scalar, a: ^Scalar)Sourcesc_set sets sc = a.
sc_set_bytes
sc_set_bytes :: proc(sc: ^Scalar, b: []u8) -> (bool)Sourcesc_set_bytes sets sc to the result of decoding b as a ristretto255 scalar, and returns true on success.
sc_set_bytes_wide
sc_set_bytes_wide :: proc(sc: ^Scalar, b: []u8)Sourcesc_set_wide_bytes sets sc to the result of deriving a ristretto255 scalar, from a wide (512-bit) byte string by interpreting b as a little-endian value, and reducing it mod the group order.
sc_set_u64
sc_set_u64 :: proc(sc: ^Scalar, i: u64)Sourcesc_set_u64 sets sc = i.
sc_square
sc_square :: proc(sc: ^Scalar, a: ^Scalar)Sourcesc_square sets sc = a^2.
sc_sub
sc_sub :: proc(sc: ^Scalar, a: ^Scalar, b: ^Scalar)Sourcesc_sub sets sc = a - b.