Skip to main content
The account module provides cryptographic account types for the Aleo blockchain. All account types are generic over a Network parameter.

PrivateKey

The root secret for an Aleo account, derived from a random seed.

Structure

Field<N>
The account seed that derives the full private key
Scalar<N>
The derived signature secret key
Scalar<N>
The derived signature randomizer

Methods

fn new<R: Rng + CryptoRng>(rng: &mut R) -> Result<Self>
Samples a new random private key
fn seed(&self) -> Field<N>
Returns the account seed
fn sk_sig(&self) -> Scalar<N>
Returns the signature secret key
fn r_sig(&self) -> Scalar<N>
Returns the signature randomizer
fn sign_bits<R: Rng + CryptoRng>(&self, message: &[bool], rng: &mut R) -> Result<Signature<N>>
Signs a message represented as bits

Example

Serialization

Private keys are serialized in Bech32 format with prefix APrivateKey1:

ViewKey

The account view key used to decrypt records and ciphertext.

Structure

Scalar<N>
The view key scalar value

Methods

fn from_scalar(view_key: Scalar<N>) -> Self
Initializes the account view key from a scalar

Derivation

The view key is derived from a private key:

Serialization

View keys use Bech32 format with prefix AViewKey1:

ComputeKey

The compute key used for program execution and record encryption.

Structure

Group<N>
The signature public key (G^sk_sig)
Group<N>
The signature public randomizer (G^r_sig)
Scalar<N>
The PRF secret key derived from pk_sig and pr_sig

Methods

fn pk_sig(&self) -> Group<N>
Returns the signature public key
fn pr_sig(&self) -> Group<N>
Returns the signature public randomizer
fn sk_prf(&self) -> Scalar<N>
Returns the PRF secret key
fn to_address(&self) -> Address<N>
Derives the address from this compute key

Example

Serialization

Compute keys use Bech32 format with prefix AComputeKey1.

Address

The unique ID of an Aleo account, derived from its view key.

Structure

Group<N>
The underlying group element representing the address

Methods

fn new(group: Group<N>) -> Self
Initializes an address from a group element
fn zero() -> Self
Initializes a zero address (for testing)

Derivation

Addresses are derived from private keys, view keys, or compute keys:

Serialization

Addresses use Bech32 format with prefix aleo1:

Signature

A digital signature proving knowledge of a private key.

Structure

Scalar<N>
The verifier challenge to check against
Scalar<N>
The prover response to the challenge
ComputeKey<N>
The compute key of the prover

Methods

fn sign<R: Rng>(private_key: &PrivateKey<N>, message: &[Field<N>], rng: &mut R) -> Result<Self>
Signs a message with a private key
fn verify(&self, address: &Address<N>, message: &[Field<N>]) -> bool
Verifies the signature against an address and message
fn verify_bits(&self, address: &Address<N>, message: &[bool]) -> bool
Verifies the signature against an address and message in bit representation
fn challenge(&self) -> Scalar<N>
Returns the verifier challenge
fn response(&self) -> Scalar<N>
Returns the prover response
fn compute_key(&self) -> ComputeKey<N>
Returns the signer compute key
fn to_address(&self) -> Address<N>
Returns the signer address

Example

Serialization

Signatures use Bech32 format with prefix sign1 (216 characters total).

Account Derivation Chain

The complete account derivation chain:
All keys derive the same address:

See Also