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

feat(WIP): secp256k1-support, rename PublicKey to VerifyingKey #134

Merged
merged 7 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
45 changes: 39 additions & 6 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ sha2 = "0.10.8"
auto_impl = "1.2.0"
bincode = "1.3.3"
ed25519-dalek = "2.1.1"
secp256k1 = "0.29.0"
secp256k1 = { version = "0.29.0", features = ["rand-std"] }
sp1-zkvm = { version = "1.2.0" }
sp1-sdk = { version = "1.2.0" }
prism-common = { path = "crates/common" }
Expand All @@ -86,6 +86,7 @@ prism-errors = { path = "crates/errors" }
prism-main = { path = "crates/prism" }
prism-groth16 = { path = "crates/groth16" }
rocksdb = { version = "0.21.0", features = ["multi-threaded-cf"] }
lazy_static = "1.5.0"


[patch.crates-io]
Expand All @@ -97,6 +98,7 @@ secp256k1 = { git = "https://github.com/sp1-patches/rust-secp256k1", branch = "p
default = []
test_utils = []
mock_prover = []
secp256k1 = []

# [workspace.dev-dependencies]
# serial_test = "3.1.1"
Expand Down
3 changes: 3 additions & 0 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ celestia-types.workspace = true
bincode.workspace = true
log.workspace = true
ed25519-dalek.workspace = true
secp256k1.workspace = true
base64.workspace = true
rand.workspace = true
lazy_static.workspace = true

[features]
default = []
test_utils = []
secp256k1 = ["secp256k1/rand-std"]
16 changes: 8 additions & 8 deletions crates/common/src/hashchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use std::{

use crate::{
operation::{
CreateAccountArgs, Operation, PublicKey, RegisterServiceArgs, ServiceChallenge,
ServiceChallengeInput,
CreateAccountArgs, Operation, RegisterServiceArgs, ServiceChallenge, ServiceChallengeInput,
VerifyingKey,
},
tree::{Digest, Hasher},
};
Expand Down Expand Up @@ -70,7 +70,7 @@ impl Hashchain {

pub fn create_account(
id: String,
value: PublicKey,
value: VerifyingKey,
signature: Vec<u8>,
service_id: String,
challenge: ServiceChallengeInput,
Expand Down Expand Up @@ -109,7 +109,7 @@ impl Hashchain {
return Ok(());
}

let mut valid_keys: HashSet<PublicKey> = HashSet::new();
let mut valid_keys: HashSet<VerifyingKey> = HashSet::new();

for (index, entry) in self.entries.iter().enumerate().take(self.entries.len() - 1) {
match &entry.operation {
Expand Down Expand Up @@ -181,15 +181,15 @@ impl Hashchain {
new
}

pub fn get_key_at_index(&self, idx: usize) -> Result<&PublicKey> {
pub fn get_key_at_index(&self, idx: usize) -> Result<&VerifyingKey> {
self.entries
.get(idx)
.and_then(|entry| entry.operation.get_public_key())
.ok_or_else(|| anyhow!("No valid public key found at index {}", idx))
}

pub fn get_valid_keys(&self) -> HashSet<PublicKey> {
let mut valid_keys: HashSet<PublicKey> = HashSet::new();
pub fn get_valid_keys(&self) -> HashSet<VerifyingKey> {
let mut valid_keys: HashSet<VerifyingKey> = HashSet::new();

for entry in self.entries.clone() {
match &entry.operation {
Expand All @@ -208,7 +208,7 @@ impl Hashchain {
valid_keys
}

pub fn is_key_revoked(&self, key: PublicKey) -> bool {
pub fn is_key_revoked(&self, key: VerifyingKey) -> bool {
self.iter()
.rev()
.find_map(|entry| match entry.operation.clone() {
Expand Down
Loading
Loading