mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Add no_std support to transcript, dalek-ff-group, ed448, ciphersuite, multiexp, schnorr, and monero-generators
transcript, dalek-ff-group, ed449, and ciphersuite are all usable with no_std alone. The rest additionally require alloc. Part of #279.
This commit is contained in:
@@ -12,13 +12,20 @@ all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[dependencies]
|
||||
std-shims = { path = "../../../common/std-shims", version = "0.1", default-features = false }
|
||||
|
||||
lazy_static = "1"
|
||||
|
||||
subtle = "^2.4"
|
||||
subtle = { version = "^2.4", default-features = false }
|
||||
|
||||
sha3 = "0.10"
|
||||
sha3 = { version = "0.10", default-features = false }
|
||||
|
||||
curve25519-dalek = { version = "3", features = ["std"] }
|
||||
curve25519-dalek = { version = "3", default-features = false }
|
||||
|
||||
group = "0.13"
|
||||
group = { version = "0.13", default-features = false }
|
||||
dalek-ff-group = { path = "../../../crypto/dalek-ff-group", version = "0.3" }
|
||||
|
||||
[features]
|
||||
alloc = ["lazy_static/spin_no_std"]
|
||||
std = ["std-shims/std"]
|
||||
default = ["std"]
|
||||
|
||||
@@ -3,3 +3,5 @@
|
||||
Generators used by Monero in both its Pedersen commitments and Bulletproofs(+).
|
||||
An implementation of Monero's `ge_fromfe_frombytes_vartime`, simply called
|
||||
`hash_to_point` here, is included, as needed to generate generators.
|
||||
|
||||
This library is usable under no_std when the `alloc` feature is enabled.
|
||||
|
||||
@@ -2,16 +2,15 @@
|
||||
//! An implementation of Monero's `ge_fromfe_frombytes_vartime`, simply called
|
||||
//! `hash_to_point` here, is included, as needed to generate generators.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
use sha3::{Digest, Keccak256};
|
||||
|
||||
use curve25519_dalek::{
|
||||
constants::ED25519_BASEPOINT_POINT,
|
||||
edwards::{EdwardsPoint as DalekPoint, CompressedEdwardsY},
|
||||
};
|
||||
use curve25519_dalek::edwards::{EdwardsPoint as DalekPoint, CompressedEdwardsY};
|
||||
|
||||
use group::Group;
|
||||
use group::{Group, GroupEncoding};
|
||||
use dalek_ff_group::EdwardsPoint;
|
||||
|
||||
mod varint;
|
||||
@@ -27,7 +26,7 @@ fn hash(data: &[u8]) -> [u8; 32] {
|
||||
lazy_static! {
|
||||
/// Monero alternate generator `H`, used for amounts in Pedersen commitments.
|
||||
pub static ref H: DalekPoint =
|
||||
CompressedEdwardsY(hash(&ED25519_BASEPOINT_POINT.compress().to_bytes()))
|
||||
CompressedEdwardsY(hash(&EdwardsPoint::generator().to_bytes()))
|
||||
.decompress()
|
||||
.unwrap()
|
||||
.mul_by_cofactor();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::io::{self, Write};
|
||||
use std_shims::io::{self, Write};
|
||||
|
||||
const VARINT_CONTINUATION_MASK: u8 = 0b1000_0000;
|
||||
pub(crate) fn write_varint<W: Write>(varint: &u64, w: &mut W) -> io::Result<()> {
|
||||
|
||||
Reference in New Issue
Block a user