Expand description
§Mina signer
This crate provides an API and framework for Mina signing. It follows the algorithm outlined in the Mina Signature Specification.
§Pallas Curve Parameters
The Mina signature scheme is built on the Pallas elliptic curve with the following field sizes:
- Base field (Fp): 254 bits, modulus =
28948022309329048855892746252171976963363056481941560715954676764349967630337
- Scalar field (Fq): 254 bits, modulus =
28948022309329048855892746252171976963363056481941647379679742748393362948097
The scalar field is larger than the base field by exactly
86663725065984043395317760
.
Both fields are approximately 2^254, making signatures 64 bytes total (32 bytes
for rx
+ 32 bytes for s
).
§Signer interface
The mina_signer
crate currently supports creating both legacy and current signers.
create_legacy
creates a legacy signer for pre-Berkeley hardfork transactionscreate_kimchi
creates the current signer for Mina mainnet (post-Berkeley hardfork)
Here is an example of how to use the signer interface to sign and verify Mina transactions.
#[path = "../tests/transaction.rs"]
mod transaction;
use rand;
use mina_signer::{NetworkId, Keypair, PubKey, Signer};
use transaction::Transaction;
let keypair = Keypair::rand(&mut rand::rngs::OsRng).expect("failed to generate keypair");
let tx = Transaction::new_payment(
keypair.public.clone(),
PubKey::from_address("B62qicipYxyEHu7QjUqS7QvBipTs5CzgkYZZZkPoKVYBu6tnDUcE9Zt").expect("invalid receiver address"),
1729000000000,
2000000000,
271828,
);
let mut ctx = mina_signer::create_legacy::<Transaction>(NetworkId::TESTNET);
let sig = ctx.sign(&keypair, &tx, false);
assert!(ctx.verify(&sig, &keypair.public, &tx));
These examples use the test
Transaction
structure found in the
./tests
directory. This is a complete reference implementation of the Mina payment and
delegation transaction structures found on mainnet and testnet.
Note: In order to sign something it must be hashed. This framework allows
you to define how types are hashed by implementing the
[Hashable
] trait – see the [mina_hasher
]
documentation
For more details about the ``mina_signer`, please see rustdoc mina-signer documentation.
§Tests
There is a standard set of signature
tests
in the
./tests
directory.
These can be run with
cargo test --package mina-signer
Re-exports§
pub use keypair::Keypair;
pub use pubkey::CompressedPubKey;
pub use pubkey::PubKey;
pub use schnorr::Schnorr;
pub use seckey::SecKey;
pub use signature::Signature;
Modules§
- keypair
- Keypair structures and algorithms
- pubkey
- Public key structures and algorithms
- schnorr
- Mina Schnorr signature scheme
- seckey
- Secret key structures and helpers
- signature
- Mina signature structure and associated helpers
Enums§
- Network
Id - Mina network (or blockchain) identifier
Traits§
- Signer
- Interface for signed objects
Functions§
- create_
kimchi - Create an experimental kimchi signer context with domain parameters
initialized with
domain_param
- create_
legacy - Create a legacy signer context with domain parameters initialized with
domain_param
Type Aliases§
- Base
Field - Base field element type
- Curve
Point - Scalar
Field - Scalar field element type