abla/crypto/bignum

Generated from source.

Import with import "abla/crypto/bignum".

Source: abla/crypto/bignum/entry.ab

BigModulusData (class)

resource class BigModulusData(val storage: NativeByteBuffer, val words: int)

The prepared form of a modulus, shared by the numbers made from it. Wiped and freed when the last of them is gone.

BigModulusData.drop (method)

trusted fun drop(): void

Wipes the prepared modulus before the buffer is freed.

BigModulus (class)

class BigModulus(val data: Shared<BigModulusData>)

An odd modulus of a fixed width, prepared for Montgomery arithmetic; a BigNumber is made by it.

BigNumber (class)

resource class BigNumber(val modulus: Shared<BigModulusData>, val storage: NativeByteBuffer, val words: int)

A value modulo a BigModulus, of that modulus's width. Dropped, its memory is wiped and freed.

BigNumber.drop (method)

trusted fun drop(): void

Wipes the value and its scratch before the buffer is freed.

bigModulus (fun)

fun bigModulus(bytes: string, bigEndian: bool = true): BigModulus?

The modulus whose value is bytes (big-endian unless bigEndian is false), or null: the size must be a multiple of 4 from 4 to 512 bytes and the value odd. The modulus is public.

BigModulus.width (extension fun)

fun BigModulus.width(): int

The width of the modulus in bytes.

BigModulus.zero (extension fun)

trusted fun BigModulus.zero(): BigNumber

Zero.

BigModulus.one (extension fun)

trusted fun BigModulus.one(): BigNumber

One.

BigModulus.number (extension fun)

trusted fun BigModulus.number(bytes: string, bigEndian: bool = true): BigNumber?

The number whose value is bytes (big-endian unless bigEndian is false), or null unless the bytes are exactly the width of the modulus and the value is below it. The check reads every byte whatever they are and only its answer (in range or not) is told, so the bytes may be a secret that is known to be in range or is refused. Bytes that may be any value of that width, or twice that, are made a number with reduce.

BigModulus.reduce (extension fun)

trusted fun BigModulus.reduce(bytes: string, bigEndian: bool = true): BigNumber?

The number whose value is bytes (big-endian unless bigEndian is false) reduced modulo the modulus, in constant time, or null unless there are 1 to twice the width of them. For a hash or a clamped key of any size up to that.

BigNumber.copy (extension fun)

trusted fun BigNumber.copy(): BigNumber

A copy of the number.

BigNumber.add (extension fun)

trusted fun BigNumber.add(other: BigNumber): BigNumber

This + other modulo the modulus. Both must belong to the same modulus.

BigNumber.sub (extension fun)

trusted fun BigNumber.sub(other: BigNumber): BigNumber

This - other modulo the modulus. Both must belong to the same modulus.

BigNumber.mul (extension fun)

trusted fun BigNumber.mul(other: BigNumber): BigNumber

This * other modulo the modulus. Both must belong to the same modulus.

BigNumber.square (extension fun)

fun BigNumber.square(): BigNumber

This * this modulo the modulus.

BigNumber.pow (extension fun)

trusted fun BigNumber.pow(exponent: string): BigNumber

This raised to the power exponent (big-endian bytes) modulo the modulus. The exponent is public: the work depends on it, never on the number.

BigNumber.select (extension fun)

trusted fun BigNumber.select(other: BigNumber, mask: secretU32): BigNumber

This where mask is all ones, other where it is zero (the mask comes from isEqual, bitMask or abla/ct). Both must belong to the same modulus.

BigNumber.isEqual (extension fun)

trusted fun BigNumber.isEqual(other: BigNumber): secretU32

All ones when the two numbers are equal, zero when not, as a secret. Both must belong to the same modulus.

BigNumber.bitMask (extension fun)

trusted fun BigNumber.bitMask(index: int): secretU32

All ones when bit index (0 is the least significant) of the value is set, else zero, as a secret. index is public and below 8 * width.

BigNumber.toBytes (extension fun)

trusted fun BigNumber.toBytes(bigEndian: bool = true): string

The value as width bytes (big-endian unless bigEndian is false). This is where a secret leaves the type: what is returned is no longer protected.

BigNumber.setMul (extension fun)

trusted fun BigNumber.setMul(a: BigNumber, b: BigNumber): void

This = a * b modulo the modulus. This may be a or b; the three must belong to the same modulus.

BigNumber.setAdd (extension fun)

trusted fun BigNumber.setAdd(a: BigNumber, b: BigNumber): void

This = a + b modulo the modulus. This may be a or b; the three must belong to the same modulus.

BigNumber.setSub (extension fun)

trusted fun BigNumber.setSub(a: BigNumber, b: BigNumber): void

This = a - b modulo the modulus. This may be a or b; the three must belong to the same modulus.

BigNumber.setSelect (extension fun)

trusted fun BigNumber.setSelect(a: BigNumber, b: BigNumber, mask: secretU32): void

This = a where mask is all ones, b where it is zero. This may be a or b; the three must belong to the same modulus.

BigNumber.set (extension fun)

trusted fun BigNumber.set(a: BigNumber): void

This = a. The two must belong to the same modulus.

Built from Abla v0.2.79 source ba5d6b7d. Examples and generated signatures follow that source revision.