Skip to content

Commit

Permalink
Factor out signature_map, for re-use in other contexts. (#1961)
Browse files Browse the repository at this point in the history
* Factor out signature_map, for re-use in other contexts.

* Fix docker build.

* Address review comments.
  • Loading branch information
przydatek authored Oct 12, 2023
1 parent a1fb583 commit b6ce489
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]
members = [
"src/internet_identity",
"src/canister_sig_util",
"src/canister_tests",
"src/internet_identity_interface",
"src/archive",
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ COPY src/internet_identity/Cargo.toml src/internet_identity/Cargo.toml
COPY src/internet_identity_interface/Cargo.toml src/internet_identity_interface/Cargo.toml
COPY src/archive/Cargo.toml src/archive/Cargo.toml
COPY src/canister_tests/Cargo.toml src/canister_tests/Cargo.toml
COPY src/canister_sig_util/Cargo.toml src/canister_sig_util/Cargo.toml
ENV CARGO_TARGET_DIR=/cargo_target
COPY ./scripts/build ./scripts/build
RUN mkdir -p src/internet_identity/src \
Expand All @@ -57,6 +58,8 @@ RUN mkdir -p src/internet_identity/src \
&& touch src/archive/src/lib.rs \
&& mkdir -p src/canister_tests/src \
&& touch src/canister_tests/src/lib.rs \
&& mkdir -p src/canister_sig_util/src \
&& touch src/canister_sig_util/src/lib.rs \
&& ./scripts/build --only-dependencies --internet-identity --archive \
&& rm -rf src

Expand Down
12 changes: 12 additions & 0 deletions src/canister_sig_util/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "canister_sig_util"
description = "Utils for handling canister signatures"
version = "0.1.0"
edition = "2021"

[dependencies]
ic-certified-map = "0.4"

[dev-dependencies]
rand = { version ="0.8.5" }
sha2 = "^0.10" # set bound to match ic-certified-map bound
1 change: 1 addition & 0 deletions src/canister_sig_util/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod signature_map;
File renamed without changes.
1 change: 1 addition & 0 deletions src/internet_identity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edition = "2021"

[dependencies]

canister_sig_util = { path = "../canister_sig_util" }
internet_identity_interface = { path = "../internet_identity_interface" }

hex = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion src/internet_identity/src/delegation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use crate::ii_domain::IIDomain;
use crate::state::persistent_state_mut;
use crate::{hash, state, update_root_hash, DAY_NS, LABEL_SIG, MINUTE_NS};
use candid::Principal;
use canister_sig_util::signature_map::SignatureMap;
use ic_cdk::api::{data_certificate, time};
use ic_cdk::{id, trap};
use ic_certified_map::{Hash, HashTree};
use internet_identity::signature_map::SignatureMap;
use internet_identity_interface::internet_identity::types::*;
use serde::Serialize;
use serde_bytes::ByteBuf;
Expand Down
3 changes: 0 additions & 3 deletions src/internet_identity/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//! Various APIs for managing internet identities.
pub mod signature_map;

/// A small module that makes get_random work on wasm32-unknown-unknown.
/// The dependency on get_random comes from the captcha library.
#[cfg(all(
Expand Down
2 changes: 1 addition & 1 deletion src/internet_identity/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use crate::storage::anchor::Anchor;
use crate::storage::DEFAULT_RANGE_SIZE;
use crate::{Salt, Storage};
use candid::{CandidType, Deserialize, Principal};
use canister_sig_util::signature_map::SignatureMap;
use ic_cdk::api::time;
use ic_cdk::{call, trap};
use ic_stable_structures::DefaultMemoryImpl;
use internet_identity::signature_map::SignatureMap;
use internet_identity_interface::internet_identity::types::*;
use std::cell::{Cell, RefCell};
use std::collections::HashMap;
Expand Down

0 comments on commit b6ce489

Please sign in to comment.