Skip to content

Commit

Permalink
Merge pull request #458 from tonlabs/1.21.2-rc
Browse files Browse the repository at this point in the history
Version 1.21.2
  • Loading branch information
d3p authored Aug 25, 2021
2 parents adff1db + 1366600 commit eeb5984
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 47 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to this project will be documented in this file.

## [1.21.2] – 2021-08-25

### Fixed
- Updated crypto libraries in order to fix building.

## [1.21.1] – 2021-08-24

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion api/derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "api_derive"
version = "1.21.1"
version = "1.21.2"
authors = ["TON DEV SOLUTIONS LTD <[email protected]>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion api/info/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "api_info"
version = "1.21.1"
version = "1.21.2"
authors = ["TON DEV SOLUTIONS LTD <[email protected]>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion api/test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "api_test"
version = "1.21.1"
version = "1.21.2"
authors = ["TON DEV SOLUTIONS LTD <[email protected]>"]
edition = "2018"

Expand Down
14 changes: 7 additions & 7 deletions ton_client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ton_client"
version = "1.21.1"
version = "1.21.2"
authors = ["TON DEV SOLUTIONS LTD <[email protected]>"]
edition = "2018"
license = "Apache-2.0"
Expand All @@ -27,7 +27,6 @@ ton_executor = { git = "https://github.com/tonlabs/ton-labs-executor.git", defau
ton_types = { git = "https://github.com/tonlabs/ton-labs-types.git" }
ton_vm = { git = "https://github.com/tonlabs/ton-labs-vm.git", default-features = false }

bip39 = { git = "https://github.com/tonlabs/bip39-rs.git" }
lockfree = { git = "https://github.com/tonlabs/lockfree.git", package = "lockfree" }
sodalite = { git = "https://github.com/tonlabs/sodalite.git", features = ["rand"] }

Expand All @@ -45,22 +44,23 @@ ed25519-dalek = "1.0.0"
failure = "0.1"
futures = "0.3.4"
hex = "0.3.2"
hmac = "0.7.1"
hmac = "0.11.0"
lazy_static = "1.1.0"
libsecp256k1 = "0.3.5"
libsecp256k1 = "0.6.0"
log = "0.4.11"
lru = "0.6.3"
num-bigint = "0.2.2"
num-derive = "0.3"
num-traits = "0.2"
pbkdf2 = { version = "0.3.0", default-features = false }
pbkdf2 = { version = "0.8.0", default-features = false }
rand = "0.7.3"
regex = "1.5.4"
scrypt = { version = "0.2.0", default-features = false }
scrypt = { version = "0.7.0", default-features = false }
serde = "1.0.91"
serde_derive = "1.0.91"
serde_json = "1.0.41"
sha2 = "0.8"
sha2 = "0.9.5"
tiny-bip39 = "0.8.0"
tokio = { version = "0.2.13", features = ["sync", "stream"], default-features = false }
zstd = { version = "0.7.0", default-features = false }

Expand Down
2 changes: 1 addition & 1 deletion ton_client/src/crypto/encscrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub fn scrypt(
) -> ClientResult<ResultOfScrypt> {
let mut key = Vec::new();
key.resize(params.dk_len as usize, 0);
let scrypt_params = scrypt::ScryptParams::new(params.log_n, params.r, params.p)
let scrypt_params = scrypt::Params::new(params.log_n, params.r, params.p)
.map_err(|err| crypto::Error::scrypt_failed(err))?;
let password = base64_decode(&params.password)?;
let salt = base64_decode(&params.salt)?;
Expand Down
8 changes: 4 additions & 4 deletions ton_client/src/crypto/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ pub fn sha256(
params: ParamsOfHash,
) -> ClientResult<ResultOfHash> {
let mut hasher = sha2::Sha256::new();
hasher.input(base64_decode(&params.data)?);
hasher.update(base64_decode(&params.data)?);
Ok(ResultOfHash {
hash: hex::encode(hasher.result().to_vec()),
hash: hex::encode(hasher.finalize().to_vec()),
})
}

Expand All @@ -50,8 +50,8 @@ pub fn sha512(
params: ParamsOfHash,
) -> ClientResult<ResultOfHash> {
let mut hasher = sha2::Sha512::new();
hasher.input(base64_decode(&params.data)?);
hasher.update(base64_decode(&params.data)?);
Ok(ResultOfHash {
hash: hex::encode(hasher.result().to_vec()),
hash: hex::encode(hasher.finalize().to_vec()),
})
}
44 changes: 22 additions & 22 deletions ton_client/src/crypto/hdkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use base58::*;
use byteorder::{BigEndian, ByteOrder, LittleEndian};
use hmac::*;
use pbkdf2::pbkdf2;
use secp256k1::{PublicKey, SecretKey};
use libsecp256k1::{SecretKey, PublicKey};
use sha2::{Digest, Sha512};
use crate::crypto::default_hdkey_compliant;

Expand Down Expand Up @@ -204,9 +204,9 @@ impl HDPrivateKey {
let salt = "mnemonic";
let mut seed = vec![0u8; 64];
pbkdf2::<Hmac<Sha512>>(phrase.as_bytes(), salt.as_bytes(), 2048, &mut seed);
let mut hmac: Hmac<Sha512> = Hmac::new_varkey(b"Bitcoin seed").unwrap();
hmac.input(&seed);
let child_chain_with_key = key512(&hmac.result().code())?;
let mut hmac: Hmac<Sha512> = Hmac::new_from_slice(b"Bitcoin seed").unwrap();
hmac.update(&seed);
let child_chain_with_key = key512(&hmac.finalize().into_bytes())?;
Ok(HDPrivateKey::master(
&key256(&child_chain_with_key[32..])?,
&key256(&child_chain_with_key[..32])?,
Expand All @@ -223,25 +223,25 @@ impl HDPrivateKey {
public_key.serialize_compressed()
}

fn map_secp_error(error: secp256k1::Error) -> ClientError {
fn map_secp_error(error: libsecp256k1::Error) -> ClientError {
match error {
secp256k1::Error::InvalidSignature => {
libsecp256k1::Error::InvalidSignature => {
crypto::Error::bip32_invalid_key("InvalidSignature")
}
secp256k1::Error::InvalidPublicKey => {
libsecp256k1::Error::InvalidPublicKey => {
crypto::Error::bip32_invalid_key("InvalidPublicKey")
}
secp256k1::Error::InvalidSecretKey => {
libsecp256k1::Error::InvalidSecretKey => {
crypto::Error::bip32_invalid_key("InvalidSecretKey")
}
secp256k1::Error::InvalidRecoveryId => {
libsecp256k1::Error::InvalidRecoveryId => {
crypto::Error::bip32_invalid_key("InvalidRecoveryId")
}
secp256k1::Error::InvalidMessage => crypto::Error::bip32_invalid_key("InvalidMessage"),
secp256k1::Error::InvalidInputLength => {
libsecp256k1::Error::InvalidMessage => crypto::Error::bip32_invalid_key("InvalidMessage"),
libsecp256k1::Error::InvalidInputLength => {
crypto::Error::bip32_invalid_key("InvalidInputLength")
}
secp256k1::Error::TweakOutOfRange => {
libsecp256k1::Error::TweakOutOfRange => {
crypto::Error::bip32_invalid_key("TweakOutOfRange")
}
}
Expand All @@ -258,8 +258,8 @@ impl HDPrivateKey {

let public = self.public();
let mut sha_hasher = sha2::Sha256::new();
sha_hasher.input(&public.as_ref());
let sha: Key256 = sha_hasher.result().into();
sha_hasher.update(&public.as_ref());
let sha: Key256 = sha_hasher.finalize().into();
let fingerprint = Ripemd160::new().update(&sha).digest();

child.parent_fingerprint.copy_from_slice(&fingerprint[0..4]);
Expand All @@ -271,24 +271,24 @@ impl HDPrivateKey {
};
BigEndian::write_u32(&mut child.child_number, child_index);

let mut hmac: Hmac<Sha512> = Hmac::new_varkey(&self.child_chain)
let mut hmac: Hmac<Sha512> = Hmac::new_from_slice(&self.child_chain)
.map_err(|err| crypto::Error::bip32_invalid_key(err))?;

let secret_key = SecretKey::parse(&self.key).unwrap();
if hardened && !compliant {
// The private key serialization in this case will not be exactly 32 bytes and can be
// any smaller value, and the value is not zero-padded.
hmac.input(&[0]);
hmac.input(&secret_key.serialize());
hmac.update(&[0]);
hmac.update(&secret_key.serialize());
} else if hardened {
// This will use a 32 byte zero padded serialization of the private key
hmac.input(&[0]);
hmac.input(&secret_key.serialize());
hmac.update(&[0]);
hmac.update(&secret_key.serialize());
} else {
hmac.input(&public);
hmac.update(&public);
}
hmac.input(&child.child_number);
let result = hmac.result().code();
hmac.update(&child.child_number);
let result = hmac.finalize().into_bytes();
let (child_key_bytes, chain_code) = result.split_at(32);

let mut child_secret_key =
Expand Down
12 changes: 6 additions & 6 deletions ton_client/src/crypto/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ pub(crate) type Key512 = [u8; 64];

pub(crate) fn sha256(bytes: &[u8]) -> Vec<u8> {
let mut hasher = sha2::Sha256::new();
hasher.input(bytes);
hasher.result().to_vec()
hasher.update(bytes);
hasher.finalize().to_vec()
}

pub(crate) fn ton_crc16(data: &[u8]) -> u16 {
Expand Down Expand Up @@ -70,14 +70,14 @@ pub(crate) fn key192(slice: &[u8]) -> ClientResult<Key192> {
}

pub(crate) fn hmac_sha512(key: &[u8], data: &[u8]) -> [u8; 64] {
let mut hmac = Hmac::<Sha512>::new_varkey(key).unwrap();
hmac.input(&data);
let mut hmac = Hmac::<Sha512>::new_from_slice(key).unwrap();
hmac.update(&data);
let mut result = [0u8; 64];
result.copy_from_slice(&hmac.result().code());
result.copy_from_slice(&hmac.finalize().into_bytes());
result
}

pub(crate) fn pbkdf2_hmac_sha512(password: &[u8], salt: &[u8], c: usize) -> [u8; 64] {
pub(crate) fn pbkdf2_hmac_sha512(password: &[u8], salt: &[u8], c: u32) -> [u8; 64] {
let mut result = [0u8; 64];
pbkdf2::pbkdf2::<Hmac<Sha512>>(password, salt, c, &mut result);
result
Expand Down
2 changes: 1 addition & 1 deletion ton_client/src/crypto/mnemonic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ impl TonMnemonic {
hmac_sha512(string.as_bytes(), &[])
}

fn seed_from_string(string: &String, salt: &str, c: usize) -> [u8; 64] {
fn seed_from_string(string: &String, salt: &str, c: u32) -> [u8; 64] {
let entropy = Self::entropy_from_string(&string);
pbkdf2_hmac_sha512(&entropy, salt.as_bytes(), c)
}
Expand Down
2 changes: 1 addition & 1 deletion ton_sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ton_sdk"
version = "1.21.1"
version = "1.21.2"
edition = "2018"
license = "Apache-2.0"
authors = ["TON DEV SOLUTIONS LTD <[email protected]>"]
Expand Down
2 changes: 1 addition & 1 deletion toncli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "toncli"
version = "1.21.1"
version = "1.21.2"
description = "TON CLient Command Line Tool"
authors = ["TON DEV SOLUTIONS LTD <[email protected]>"]
repository = "https://github.com/tonlabs/TON-SDK"
Expand Down
2 changes: 1 addition & 1 deletion tools/api.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.21.1",
"version": "1.21.2",
"modules": [
{
"name": "client",
Expand Down

0 comments on commit eeb5984

Please sign in to comment.