Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Rust implementation #174

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ include = [
"/README.md",
"build.rs",
"src/*.rs",
"src/*/*.rs",
"/depend/check_uint128_t.c",
"/depend/zcash/src/amount.cpp",
"/depend/zcash/src/amount.h",
Expand Down Expand Up @@ -62,6 +63,7 @@ rust-interpreter = []

[dependencies]
bitflags = "2.5"
log = "0.4"

[build-dependencies]
# The `bindgen` dependency should automatically upgrade to match the version used by zebra-state's `rocksdb` dependency in:
Expand Down
4 changes: 4 additions & 0 deletions src/external/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//! Modules that we use from Zcash, but that are outside the script directory.
nuttycom marked this conversation as resolved.
Show resolved Hide resolved

pub mod pubkey;
pub mod uint256;
23 changes: 23 additions & 0 deletions src/external/pubkey.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use super::uint256::*;

/// FIXME: `PUBLIC_KEY_SIZE` is meant to be an upper bound, it seems. Maybe parameterize the type
/// over the size.
pub struct PubKey<'a>(pub &'a [u8]);

impl PubKey<'_> {
pub const PUBLIC_KEY_SIZE: usize = 65;
pub const COMPRESSED_PUBLIC_KEY_SIZE: usize = 33;

/// Check syntactic correctness.
///
/// Note that this is consensus critical as CheckSig() calls it!
pub fn is_valid(&self) -> bool {
self.0.len() > 0
}

/// Verify a DER signature (~72 bytes).
/// If this public key is not fully valid, the return value will be false.
pub fn verify(&self, hash: &UInt256, vch_sig: &[u8]) -> bool {
todo!()
}
}
2 changes: 2 additions & 0 deletions src/external/uint256.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// FIXME: This probably needs to be an actually separate type somewhere.
pub type UInt256 = [u8; 32];
sellout marked this conversation as resolved.
Show resolved Hide resolved
Loading