Skip to content

Commit 72856ae

Browse files
authored
Merge pull request #60 from brave-intl/bump-base64
bump base64 to 0.22
2 parents 6b30d6a + 4011699 commit 72856ae

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
lines changed

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
authors = ["eV <[email protected]>"]
33
edition = "2018"
44
name = "challenge-bypass-ristretto"
5-
version = "2.0.1"
5+
version = "2.0.2"
66
readme = "README.md"
77
license = "MPL-2.0"
88
repository = "https://github.com/brave-intl/challenge-bypass-ristretto"
@@ -25,7 +25,7 @@ zeroize = "1.3"
2525

2626
[dependencies.base64]
2727
optional = true
28-
version = "0.13"
28+
version = "0.22"
2929

3030
[dependencies.serde]
3131
optional = true
@@ -36,7 +36,7 @@ default-features = false
3636
serde_json = "=1.0.140"
3737
serde = { version = "=1.0.219", features = ["derive"] }
3838
sha2 = "=0.10.8"
39-
base64 = "=0.13.1"
39+
base64 = "0.22"
4040
rand = { version = "=0.8.5", default-features = true }
4141
criterion = { version = "=0.5.1", features = ["html_reports"] }
4242

@@ -45,6 +45,7 @@ default = ["std"]
4545
std = ["alloc", "subtle/std"]
4646
alloc = ["curve25519-dalek/alloc"]
4747
serde_base64 = ["serde", "base64"]
48+
cbindgen = []
4849

4950
[package.metadata.docs.rs]
5051
rustdoc-args = [
@@ -56,4 +57,3 @@ rustdoc-args = [
5657
[[bench]]
5758
name = "benchmarks"
5859
harness = false
59-

src/dleq.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ impl BatchDLEQProof {
352352

353353
#[cfg(test)]
354354
mod tests {
355+
use base64::{engine::Engine as _, prelude::BASE64_STANDARD};
355356
use curve25519_dalek::ristretto::CompressedRistretto;
356357
use rand::rngs::OsRng;
357358
use sha2::Sha512;
@@ -398,14 +399,14 @@ mod tests {
398399

399400
assert_eq!(server_key.public_key.encode_base64(), Y);
400401

401-
let P_bytes = base64::decode(P).unwrap();
402+
let P_bytes = BASE64_STANDARD.decode(P).unwrap();
402403
let mut P_bits: [u8; 32] = [0u8; 32];
403404
P_bits.copy_from_slice(&P_bytes[..32]);
404405
let P = CompressedRistretto(P_bits).decompress().unwrap();
405406

406407
let Q = P * server_key.k;
407408

408-
assert_eq!(base64::encode(&Q.compress().to_bytes()[..]), Q_b64);
409+
assert_eq!(BASE64_STANDARD.encode(&Q.compress().to_bytes()[..]), Q_b64);
409410

410411
let seed: [u8; 32] = [0u8; 32];
411412
let mut prng: ChaChaRng = SeedableRng::from_seed(seed);
@@ -455,8 +456,8 @@ mod tests {
455456
BatchDLEQProof::calculate_composites::<Sha512>(&P, &Q, &server_key.public_key)
456457
.unwrap();
457458

458-
assert_eq!(base64::encode(&M.compress().to_bytes()[..]), M_b64);
459-
assert_eq!(base64::encode(&Z.compress().to_bytes()[..]), Z_b64);
459+
assert_eq!(BASE64_STANDARD.encode(&M.compress().to_bytes()[..]), M_b64);
460+
assert_eq!(BASE64_STANDARD.encode(&Z.compress().to_bytes()[..]), Z_b64);
460461

461462
let seed: [u8; 32] = [0u8; 32];
462463
let mut prng: ChaChaRng = SeedableRng::from_seed(seed);

src/macros.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,23 @@ macro_rules! impl_base64 {
77
#[cfg(all(feature = "alloc", not(feature = "std")))]
88
/// Encode to a base64 string
99
pub fn encode_base64(&self) -> ::alloc::string::String {
10-
::base64::encode(&self.to_bytes()[..])
10+
use base64::Engine;
11+
base64::prelude::BASE64_STANDARD.encode(&self.to_bytes().to_vec())
1112
}
1213

1314
#[cfg(all(feature = "std"))]
1415
/// Encode to a base64 string
1516
pub fn encode_base64(&self) -> ::std::string::String {
16-
::base64::encode(&self.to_bytes()[..])
17+
use base64::Engine;
18+
base64::prelude::BASE64_STANDARD.encode(&self.to_bytes().to_vec())
1719
}
1820

1921
/// Decode from a base64 string
2022
pub fn decode_base64(s: &str) -> Result<Self, TokenError> {
21-
let bytes =
22-
::base64::decode(s).or(Err(TokenError(InternalError::DecodingError)))?;
23+
use base64::Engine;
24+
let bytes = base64::prelude::BASE64_STANDARD
25+
.decode(s)
26+
.or(Err(TokenError(InternalError::DecodingError)))?;
2327
$t::from_bytes(&bytes)
2428
}
2529
}

src/oprf.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ impl VerificationSignature {
580580

581581
#[cfg(test)]
582582
mod tests {
583+
use base64::{engine::Engine as _, prelude::BASE64_STANDARD};
583584
use hmac::Hmac;
584585
use rand::rngs::OsRng;
585586
use sha2::Sha512;
@@ -605,11 +606,11 @@ mod tests {
605606
];
606607
for (k, Y, seed, r, P, Q, W) in vectors {
607608
let server_key = SigningKey::decode_base64(k).unwrap();
608-
let seed = base64::decode(seed).unwrap();
609+
let seed = BASE64_STANDARD.decode(seed).unwrap();
609610

610611
assert!(server_key.public_key.encode_base64() == Y);
611612

612-
let r_bytes = base64::decode(r).unwrap();
613+
let r_bytes = BASE64_STANDARD.decode(r).unwrap();
613614
let mut r_bits: [u8; 32] = [0u8; 32];
614615
r_bits.copy_from_slice(&r_bytes);
615616
let r = Scalar::from_canonical_bytes(r_bits).unwrap();
@@ -626,7 +627,7 @@ mod tests {
626627

627628
let unblinded_token = token.unblind(&signed_token).unwrap();
628629

629-
let W_bytes = base64::decode(W).unwrap();
630+
let W_bytes = BASE64_STANDARD.decode(W).unwrap();
630631
let mut W_bits: [u8; 32] = [0u8; 32];
631632
W_bits.copy_from_slice(&W_bytes[..32]);
632633
let W = CompressedRistretto(W_bits);

0 commit comments

Comments
 (0)