mirror of
https://github.com/saymrwulf/risc0-curve25519-dalek-source.git
synced 2026-09-07 20:30:39 +00:00
Create new module for constants.
This commit is contained in:
parent
eb8ab9f06b
commit
80e72db677
3 changed files with 36 additions and 23 deletions
31
src/constants.rs
Normal file
31
src/constants.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
// -*- mode: rust; -*-
|
||||||
|
//
|
||||||
|
// This file is part of ed25519-dalek.
|
||||||
|
// Copyright (c) 2017-2018 isis lovecruft
|
||||||
|
// See LICENSE for licensing information.
|
||||||
|
//
|
||||||
|
// Authors:
|
||||||
|
// - isis agora lovecruft <isis@patternsinthevoid.net>
|
||||||
|
|
||||||
|
//! Common constants such as buffer sizes for keypairs and signatures.
|
||||||
|
|
||||||
|
/// The length of a ed25519 `Signature`, in bytes.
|
||||||
|
pub const SIGNATURE_LENGTH: usize = 64;
|
||||||
|
|
||||||
|
/// The length of a ed25519 `SecretKey`, in bytes.
|
||||||
|
pub const SECRET_KEY_LENGTH: usize = 32;
|
||||||
|
|
||||||
|
/// The length of an ed25519 `PublicKey`, in bytes.
|
||||||
|
pub const PUBLIC_KEY_LENGTH: usize = 32;
|
||||||
|
|
||||||
|
/// The length of an ed25519 `Keypair`, in bytes.
|
||||||
|
pub const KEYPAIR_LENGTH: usize = SECRET_KEY_LENGTH + PUBLIC_KEY_LENGTH;
|
||||||
|
|
||||||
|
/// The length of the "key" portion of an "expanded" ed25519 secret key, in bytes.
|
||||||
|
const EXPANDED_SECRET_KEY_KEY_LENGTH: usize = 32;
|
||||||
|
|
||||||
|
/// The length of the "nonce" portion of an "expanded" ed25519 secret key, in bytes.
|
||||||
|
const EXPANDED_SECRET_KEY_NONCE_LENGTH: usize = 32;
|
||||||
|
|
||||||
|
/// The length of an "expanded" ed25519 key, `ExpandedSecretKey`, in bytes.
|
||||||
|
pub const EXPANDED_SECRET_KEY_LENGTH: usize = EXPANDED_SECRET_KEY_KEY_LENGTH + EXPANDED_SECRET_KEY_NONCE_LENGTH;
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
// -*- mode: rust; -*-
|
// -*- mode: rust; -*-
|
||||||
//
|
//
|
||||||
// This file is part of ed25519-dalek.
|
// This file is part of ed25519-dalek.
|
||||||
// Copyright (c) 2017-2018 Isis Lovecruft
|
// Copyright (c) 2017-2018 isis lovecruft
|
||||||
// See LICENSE for licensing information.
|
// See LICENSE for licensing information.
|
||||||
//
|
//
|
||||||
// Authors:
|
// Authors:
|
||||||
// - Isis Agora Lovecruft <isis@patternsinthevoid.net>
|
// - isis agora lovecruft <isis@patternsinthevoid.net>
|
||||||
|
|
||||||
//! A Rust implementation of ed25519 key generation, signing, and verification.
|
//! A Rust implementation of ed25519 key generation, signing, and verification.
|
||||||
|
|
||||||
|
|
@ -36,30 +36,11 @@ use curve25519_dalek::edwards::CompressedEdwardsY;
|
||||||
use curve25519_dalek::edwards::EdwardsPoint;
|
use curve25519_dalek::edwards::EdwardsPoint;
|
||||||
use curve25519_dalek::scalar::Scalar;
|
use curve25519_dalek::scalar::Scalar;
|
||||||
|
|
||||||
|
pub use constants::*;
|
||||||
|
|
||||||
use errors::SignatureError;
|
use errors::SignatureError;
|
||||||
use errors::InternalError;
|
use errors::InternalError;
|
||||||
|
|
||||||
/// The length of a ed25519 `Signature`, in bytes.
|
|
||||||
pub const SIGNATURE_LENGTH: usize = 64;
|
|
||||||
|
|
||||||
/// The length of a ed25519 `SecretKey`, in bytes.
|
|
||||||
pub const SECRET_KEY_LENGTH: usize = 32;
|
|
||||||
|
|
||||||
/// The length of an ed25519 `PublicKey`, in bytes.
|
|
||||||
pub const PUBLIC_KEY_LENGTH: usize = 32;
|
|
||||||
|
|
||||||
/// The length of an ed25519 `Keypair`, in bytes.
|
|
||||||
pub const KEYPAIR_LENGTH: usize = SECRET_KEY_LENGTH + PUBLIC_KEY_LENGTH;
|
|
||||||
|
|
||||||
/// The length of the "key" portion of an "expanded" ed25519 secret key, in bytes.
|
|
||||||
const EXPANDED_SECRET_KEY_KEY_LENGTH: usize = 32;
|
|
||||||
|
|
||||||
/// The length of the "nonce" portion of an "expanded" ed25519 secret key, in bytes.
|
|
||||||
const EXPANDED_SECRET_KEY_NONCE_LENGTH: usize = 32;
|
|
||||||
|
|
||||||
/// The length of an "expanded" ed25519 key, `ExpandedSecretKey`, in bytes.
|
|
||||||
pub const EXPANDED_SECRET_KEY_LENGTH: usize = EXPANDED_SECRET_KEY_KEY_LENGTH + EXPANDED_SECRET_KEY_NONCE_LENGTH;
|
|
||||||
|
|
||||||
/// An EdDSA signature.
|
/// An EdDSA signature.
|
||||||
///
|
///
|
||||||
/// # Note
|
/// # Note
|
||||||
|
|
|
||||||
|
|
@ -261,6 +261,7 @@ extern crate serde;
|
||||||
#[cfg(all(test, feature = "serde"))]
|
#[cfg(all(test, feature = "serde"))]
|
||||||
extern crate bincode;
|
extern crate bincode;
|
||||||
|
|
||||||
|
mod constants;
|
||||||
mod ed25519;
|
mod ed25519;
|
||||||
|
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue