From 41d6fed5fd68725475ab7f1b82b50e460ef785d7 Mon Sep 17 00:00:00 2001 From: xjd Date: Fri, 12 Jan 2024 18:31:13 +0800 Subject: [PATCH] Add missing auth id(0x02~0x05) migrate PR from: https://github.com/nervosnetwork/ckb-production-scripts/pull/75 including * eos * tron * bitcoin(Support UniSat and OKX wallet) * dogecoin Special feature for btc/etc, now they can display meaningful messages. * BTC(UniSat/OKX) You're signing: CKB (Bitcoin Layer-2) transaction: 0x{sighash_all in hex} * ETH(Metamask) You're signing: CKB transaction: 0x{sighash_all in hex} --- c/ckb_identity.h | 4 ++ tests/omni_lock_rust/build.rs | 82 ----------------------------------- 2 files changed, 4 insertions(+), 82 deletions(-) delete mode 100644 tests/omni_lock_rust/build.rs diff --git a/c/ckb_identity.h b/c/ckb_identity.h index dbdb1c1..f006f8b 100644 --- a/c/ckb_identity.h +++ b/c/ckb_identity.h @@ -25,7 +25,11 @@ #define MAX_PREIMAGE_SIZE 1024 #define MESSAGE_HEX_LEN 64 +<<<<<<< HEAD const char BTC_PREFIX[] = "CKB (Bitcoin Layer) transaction: 0x"; +======= +const char BTC_PREFIX[] = "CKB (Bitcoin Layer-2) transaction: 0x"; +>>>>>>> bcd9b58 (Add missing auth id(0x02~0x05)) // BTC_PREFIX_LEN = 35 const size_t BTC_PREFIX_LEN = sizeof(BTC_PREFIX) - 1; diff --git a/tests/omni_lock_rust/build.rs b/tests/omni_lock_rust/build.rs deleted file mode 100644 index b0b2821..0000000 --- a/tests/omni_lock_rust/build.rs +++ /dev/null @@ -1,82 +0,0 @@ -pub use blake2b_rs::{Blake2b, Blake2bBuilder}; -use includedir_codegen::Compression; - -use std::{ - env, - fs::File, - io::{BufWriter, Read, Write}, - path::Path, -}; - -const PATH_PREFIX: &str = "../../build/"; -const BUF_SIZE: usize = 8 * 1024; -const CKB_HASH_PERSONALIZATION: &[u8] = b"ckb-default-hash"; - -const BINARIES: &[(&str, &str)] = &[ - ( - "omni_lock", - "768f306681da232ceb0b94f436c5f813377179762a831c5ad8797bd4fd2d118d", - ), -]; - -fn main() { - let mut bundled = includedir_codegen::start("BUNDLED_CELL"); - - let out_path = Path::new(&env::var("OUT_DIR").unwrap()).join("code_hashes.rs"); - let mut out_file = BufWriter::new(File::create(&out_path).expect("create code_hashes.rs")); - - let mut errors = Vec::new(); - - for (name, expected_hash) in BINARIES { - let path = format!("{}{}", PATH_PREFIX, name); - - let mut buf = [0u8; BUF_SIZE]; - bundled - .add_file(&path, Compression::Gzip) - .expect("add files to resource bundle"); - - // build hash - let mut blake2b = new_blake2b(); - let mut fd = File::open(&path).expect("open file"); - loop { - let read_bytes = fd.read(&mut buf).expect("read file"); - if read_bytes > 0 { - blake2b.update(&buf[..read_bytes]); - } else { - break; - } - } - - let mut hash = [0u8; 32]; - blake2b.finalize(&mut hash); - - let actual_hash = faster_hex::hex_string(&hash).unwrap(); - if expected_hash != &actual_hash { - errors.push((name, expected_hash, actual_hash)); - continue; - } - - write!( - &mut out_file, - "pub const {}: [u8; 32] = {:?};\n", - format!("CODE_HASH_{}", name.to_uppercase()), - hash - ) - .expect("write to code_hashes.rs"); - } - - if !errors.is_empty() { - for (name, expected, actual) in errors.into_iter() { - eprintln!("{}: expect {}, actual {}", name, expected, actual); - } - panic!("not all hashes are right"); - } - - bundled.build("bundled.rs").expect("build resource bundle"); -} - -pub fn new_blake2b() -> Blake2b { - Blake2bBuilder::new(32) - .personal(CKB_HASH_PERSONALIZATION) - .build() -}