Skip to content

Commit

Permalink
chore: re-remove BigUint and OID imports (#220)
Browse files Browse the repository at this point in the history
* chore: re-remove `BigUint` and `OID` imports

But this time bump `simple_asn1` to the patch that forces this to work (older versions don't use the `$crate::` idiom which enable this to work).

* chore: cleanup imports

`cargo fmt -- --config imports_granularity="Crate"`
  • Loading branch information
Daniel-Bloom-dfinity authored Jul 2, 2021
1 parent 20694f2 commit 88606ec
Show file tree
Hide file tree
Showing 46 changed files with 252 additions and 304 deletions.
2 changes: 1 addition & 1 deletion ic-agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ring = { version = "0.16.11", features = ["std"] }
serde = { version = "1.0.101", features = ["derive"] }
serde_bytes = "0.11.2"
serde_cbor = "0.11.1"
simple_asn1 = "0.5.0"
simple_asn1 = "0.5.4"
thiserror = "1.0.20"
url = "2.1.0"
webpki-roots = "0.20.0"
Expand Down
7 changes: 4 additions & 3 deletions ic-agent/src/agent/agent_config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::agent::{NonceFactory, ReplicaV2Transport};
use crate::identity::anonymous::AnonymousIdentity;
use crate::identity::Identity;
use crate::{
agent::{NonceFactory, ReplicaV2Transport},
identity::{anonymous::AnonymousIdentity, Identity},
};
use std::sync::Arc;

/// A configuration for an agent.
Expand Down
10 changes: 5 additions & 5 deletions ic-agent/src/agent/agent_error.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::agent::status::Status;
use crate::hash_tree::Label;
use crate::RequestIdError;
use crate::{agent::status::Status, hash_tree::Label, RequestIdError};
use leb128::read;
use std::fmt::{Debug, Display, Formatter};
use std::str::Utf8Error;
use std::{
fmt::{Debug, Display, Formatter},
str::Utf8Error,
};
use thiserror::Error;

#[derive(Error, Debug)]
Expand Down
12 changes: 8 additions & 4 deletions ic-agent/src/agent/agent_test.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// Disable these tests without the reqwest feature.
#![cfg(feature = "reqwest")]

use crate::agent::replica_api::{CallReply, QueryResponse};
use crate::agent::Status;
use crate::export::Principal;
use crate::{Agent, AgentError};
use crate::{
agent::{
replica_api::{CallReply, QueryResponse},
Status,
},
export::Principal,
Agent, AgentError,
};
use mockito::mock;
use std::collections::BTreeMap;

Expand Down
6 changes: 4 additions & 2 deletions ic-agent/src/agent/builder.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::agent::{AgentConfig, ReplicaV2Transport};
use crate::{Agent, AgentError, Identity, NonceFactory};
use crate::{
agent::{AgentConfig, ReplicaV2Transport},
Agent, AgentError, Identity, NonceFactory,
};
use std::sync::Arc;

pub struct AgentBuilder {
Expand Down
8 changes: 2 additions & 6 deletions ic-agent/src/agent/http_transport.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
//! A [ReplicaV2Transport] that connects using a reqwest client.
#![cfg(feature = "reqwest")]

use crate::agent::agent_error::HttpErrorPayload;
use crate::ic_types::Principal;
use crate::AgentError;
use crate::RequestId;
use crate::{agent::agent_error::HttpErrorPayload, ic_types::Principal, AgentError, RequestId};
use reqwest::Method;
use std::future::Future;
use std::pin::Pin;
use std::{future::Future, pin::Pin};

/// Implemented by the Agent environment to cache and update an HTTP Auth password.
/// It returns a tuple of `(username, password)`.
Expand Down
38 changes: 22 additions & 16 deletions ic-agent/src/agent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,34 @@ pub use response::{Replied, RequestStatusResponse};
#[cfg(test)]
mod agent_test;

use crate::agent::replica_api::{
CallRequestContent, Certificate, Delegation, Envelope, QueryContent, ReadStateContent,
ReadStateResponse,
use crate::{
agent::replica_api::{
CallRequestContent, Certificate, Delegation, Envelope, QueryContent, ReadStateContent,
ReadStateResponse,
},
export::Principal,
hash_tree::Label,
identity::Identity,
to_request_id, RequestId,
};
use crate::export::Principal;
use crate::hash_tree::Label;
use crate::identity::Identity;
use crate::{to_request_id, RequestId};
use garcon::Waiter;
use serde::Serialize;
use status::Status;

use crate::agent::response_authentication::{
extract_der, initialize_bls, lookup_canister_info, lookup_request_status, lookup_value,
use crate::{
agent::response_authentication::{
extract_der, initialize_bls, lookup_canister_info, lookup_request_status, lookup_value,
},
bls::bls12381::bls,
};
use std::{
convert::TryFrom,
future::Future,
pin::Pin,
sync::{Arc, RwLock},
task::{Context, Poll},
time::Duration,
};
use crate::bls::bls12381::bls;
use std::convert::TryFrom;
use std::future::Future;
use std::pin::Pin;
use std::sync::{Arc, RwLock};
use std::task::{Context, Poll};
use std::time::Duration;

const IC_REQUEST_DOMAIN_SEPARATOR: &[u8; 11] = b"\x0Aic-request";
const IC_STATE_ROOT_DOMAIN_SEPARATOR: &[u8; 14] = b"\x0Dic-state-root";
Expand Down
3 changes: 1 addition & 2 deletions ic-agent/src/agent/nonce.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use rand::rngs::OsRng;
use rand::Rng;
use rand::{rngs::OsRng, Rng};
use std::sync::{Arc, Mutex};

/// A Factory for nonce blobs.
Expand Down
6 changes: 4 additions & 2 deletions ic-agent/src/agent/replica_api.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::export::Principal;
use crate::hash_tree::{HashTree, Label};
use crate::{
export::Principal,
hash_tree::{HashTree, Label},
};
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Deserialize, Serialize)]
Expand Down
12 changes: 6 additions & 6 deletions ic-agent/src/agent/response_authentication.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::{ic_types::Principal, AgentError, RequestId};

use crate::agent::replica_api::Certificate;
use crate::agent::{Replied, RequestStatusResponse};
use crate::bls::bls12381::bls;
use crate::hash_tree::{Label, LookupResult};
use std::str::from_utf8;
use std::sync::Once;
use crate::{
agent::{replica_api::Certificate, Replied, RequestStatusResponse},
bls::bls12381::bls,
hash_tree::{Label, LookupResult},
};
use std::{str::from_utf8, sync::Once};

const DER_PREFIX: &[u8; 37] = b"\x30\x81\x82\x30\x1d\x06\x0d\x2b\x06\x01\x04\x01\x82\xdc\x7c\x05\x03\x01\x02\x01\x06\x0c\x2b\x06\x01\x04\x01\x82\xdc\x7c\x05\x03\x02\x01\x03\x61\x00";
const KEY_LENGTH: usize = 96;
Expand Down
3 changes: 1 addition & 2 deletions ic-agent/src/agent/signed.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::export::Principal;
use crate::RequestId;
use crate::{export::Principal, RequestId};

use serde::{Deserialize, Serialize};

Expand Down
3 changes: 1 addition & 2 deletions ic-agent/src/agent/status.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::collections::BTreeMap;
use std::fmt::Debug;
use std::{collections::BTreeMap, fmt::Debug};

/// Value returned by the status endpoint of a replica. This is a loose mapping to CBOR values.
/// Because the agent should not return [`serde_cbor::Value`] directly across API boundaries,
Expand Down
6 changes: 2 additions & 4 deletions ic-agent/src/bls/bls12381/big.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
* limitations under the License.
*/

use crate::bls::arch;
use crate::bls::arch::Chunk;
use crate::bls::{arch, arch::Chunk};

use crate::bls::arch::DChunk;

use crate::bls::bls12381::dbig::DBIG;
use crate::bls::rand::RAND;
use crate::bls::{bls12381::dbig::DBIG, rand::RAND};

pub const MODBYTES: usize = 48;
pub const BASEBITS: usize = 58;
Expand Down
15 changes: 4 additions & 11 deletions ic-agent/src/bls/bls12381/bls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use crate::bls::bls12381::big;
use crate::bls::bls12381::big::BIG;
use crate::bls::bls12381::dbig::DBIG;
use crate::bls::bls12381::ecp;
use crate::bls::bls12381::ecp::ECP;
use crate::bls::bls12381::ecp2::ECP2;
use crate::bls::bls12381::fp::FP;
use crate::bls::bls12381::fp4::FP4;
use crate::bls::bls12381::pair;
use crate::bls::bls12381::rom;
use crate::bls::hmac;
use crate::bls::{
bls12381::{big, big::BIG, dbig::DBIG, ecp, ecp::ECP, ecp2::ECP2, fp::FP, fp4::FP4, pair, rom},
hmac,
};

/* Boneh-Lynn-Shacham signature 128-bit API Functions */

Expand Down
9 changes: 5 additions & 4 deletions ic-agent/src/bls/bls12381/dbig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
* limitations under the License.
*/

use crate::bls::arch;
use crate::bls::arch::Chunk;
use crate::bls::bls12381::big;
use crate::bls::bls12381::big::BIG;
use crate::bls::{
arch,
arch::Chunk,
bls12381::{big, big::BIG},
};

pub struct DBIG {
pub w: [Chunk; big::DNLEN],
Expand Down
7 changes: 1 addition & 6 deletions ic-agent/src/bls/bls12381/ecp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@
* limitations under the License.
*/

use crate::bls::bls12381::big;
use crate::bls::bls12381::big::BIG;
use crate::bls::bls12381::dbig::DBIG;
use crate::bls::bls12381::fp;
use crate::bls::bls12381::fp::FP;
use crate::bls::bls12381::rom;
use crate::bls::bls12381::{big, big::BIG, dbig::DBIG, fp, fp::FP, rom};

#[derive(Clone)]
pub struct ECP {
Expand Down
9 changes: 1 addition & 8 deletions ic-agent/src/bls/bls12381/ecp2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@
* limitations under the License.
*/

use crate::bls::bls12381::big;
use crate::bls::bls12381::big::BIG;
use crate::bls::bls12381::dbig::DBIG;
use crate::bls::bls12381::ecp;
use crate::bls::bls12381::fp;
use crate::bls::bls12381::fp::FP;
use crate::bls::bls12381::fp2::FP2;
use crate::bls::bls12381::rom;
use crate::bls::bls12381::{big, big::BIG, dbig::DBIG, ecp, fp, fp::FP, fp2::FP2, rom};

#[derive(Clone)]
pub struct ECP2 {
Expand Down
11 changes: 5 additions & 6 deletions ic-agent/src/bls/bls12381/fp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
* limitations under the License.
*/

use crate::bls::arch;
use crate::bls::arch::Chunk;
use crate::bls::bls12381::big;
use crate::bls::bls12381::big::BIG;
use crate::bls::bls12381::dbig::DBIG;
use crate::bls::bls12381::rom;
use crate::bls::{
arch,
arch::Chunk,
bls12381::{big, big::BIG, dbig::DBIG, rom},
};

use crate::bls::rand::RAND;

Expand Down
8 changes: 1 addition & 7 deletions ic-agent/src/bls/bls12381/fp12.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@
* limitations under the License.
*/

use crate::bls::bls12381::big;
use crate::bls::bls12381::big::BIG;
use crate::bls::bls12381::ecp;
use crate::bls::bls12381::fp::FP;
use crate::bls::bls12381::fp2::FP2;
use crate::bls::bls12381::fp4::FP4;
use crate::bls::bls12381::rom;
use crate::bls::bls12381::{big, big::BIG, ecp, fp::FP, fp2::FP2, fp4::FP4, rom};

pub const ZERO: usize = 0;
pub const ONE: usize = 1;
Expand Down
7 changes: 1 addition & 6 deletions ic-agent/src/bls/bls12381/fp2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@
* limitations under the License.
*/

use crate::bls::bls12381::big;
use crate::bls::bls12381::big::BIG;
use crate::bls::bls12381::dbig::DBIG;
use crate::bls::bls12381::fp;
use crate::bls::bls12381::fp::FP;
use crate::bls::bls12381::rom;
use crate::bls::bls12381::{big, big::BIG, dbig::DBIG, fp, fp::FP, rom};

use crate::bls::rand::RAND;

Expand Down
10 changes: 4 additions & 6 deletions ic-agent/src/bls/bls12381/fp4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@
* limitations under the License.
*/

use crate::bls::bls12381::big;
use crate::bls::bls12381::big::BIG;
use crate::bls::bls12381::fp;
use crate::bls::bls12381::fp::FP;
use crate::bls::bls12381::fp2::FP2;
#[allow(unused_imports)]
use crate::bls::bls12381::rom;
use crate::bls::rand::RAND;
use crate::bls::{
bls12381::{big, big::BIG, fp, fp::FP, fp2::FP2},
rand::RAND,
};

#[derive(Copy, Clone)]
pub struct FP4 {
Expand Down
18 changes: 5 additions & 13 deletions ic-agent/src/bls/bls12381/mpin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,11 @@
* limitations under the License.
*/

use crate::bls::bls12381::big;
use crate::bls::bls12381::big::BIG;
use crate::bls::bls12381::dbig::DBIG;
use crate::bls::bls12381::ecp;
use crate::bls::bls12381::ecp::ECP;
use crate::bls::bls12381::ecp2::ECP2;
use crate::bls::bls12381::fp::FP;
use crate::bls::bls12381::fp12::FP12;
use crate::bls::bls12381::pair;
use crate::bls::bls12381::rom;

use crate::bls::hmac;
use crate::bls::rand::RAND;
use crate::bls::bls12381::{
big, big::BIG, dbig::DBIG, ecp, ecp::ECP, ecp2::ECP2, fp::FP, fp12::FP12, pair, rom,
};

use crate::bls::{hmac, rand::RAND};

/* MPIN 128-bit API Functions */

Expand Down
13 changes: 3 additions & 10 deletions ic-agent/src/bls/bls12381/pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,9 @@
* limitations under the License.
*/

use crate::bls::bls12381::big::BIG;
use crate::bls::bls12381::ecp;
use crate::bls::bls12381::ecp::ECP;
use crate::bls::bls12381::ecp2::ECP2;
use crate::bls::bls12381::fp::FP;
use crate::bls::bls12381::fp12;
use crate::bls::bls12381::fp12::FP12;
use crate::bls::bls12381::fp2::FP2;
use crate::bls::bls12381::fp4::FP4;
use crate::bls::bls12381::rom;
use crate::bls::bls12381::{
big::BIG, ecp, ecp::ECP, ecp2::ECP2, fp::FP, fp12, fp12::FP12, fp2::FP2, fp4::FP4, rom,
};

#[allow(unused_imports)]
use crate::bls::bls12381::dbig::DBIG;
Expand Down
3 changes: 1 addition & 2 deletions ic-agent/src/bls/bls12381/rom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
* limitations under the License.
*/

use crate::bls::arch::Chunk;
use crate::bls::bls12381::big::NLEN;
use crate::bls::{arch::Chunk, bls12381::big::NLEN};

// Base Bits= 58
// bls12381 Modulus
Expand Down
3 changes: 1 addition & 2 deletions ic-agent/src/bls/gcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ const GCM_FINISHED: usize = 3;
//const GCM_ENCRYPTING: usize = 0;
//const GCM_DECRYPTING: usize = 1;

use crate::bls::aes;
use crate::bls::aes::AES;
use crate::bls::{aes, aes::AES};

pub struct GCM {
table: [[u32; 4]; 128],
Expand Down
Loading

0 comments on commit 88606ec

Please sign in to comment.