Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable EOS #11

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 1 addition & 30 deletions c/ckb_identity.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ enum IdentityFlagsType {
IdentityFlagsCkb = 0,
// values 1~5 are used by pw-lock
IdentityFlagsEthereum = 1,
IdentityFlagsEos = 2,
// EOS = 2, disabled
IdentityFlagsTron = 3,
IdentityFlagsBitcoin = 4,
IdentityFlagsDogecoin = 5,
Expand Down Expand Up @@ -351,29 +351,6 @@ int validate_signature_btc(void *prefilled_data, const uint8_t *sig,
return 0;
}

int validate_signature_eos(void *prefilled_data, const uint8_t *sig,
size_t sig_len, const uint8_t *msg, size_t msg_len,
uint8_t *output, size_t *output_len) {
int err = 0;
if (*output_len < AUTH160_SIZE) {
return ERROR_INVALID_ARG;
}
uint8_t out_pubkey[UNCOMPRESSED_SECP256K1_PUBKEY_SIZE];
size_t out_pubkey_size = UNCOMPRESSED_SECP256K1_PUBKEY_SIZE;
err = _recover_secp256k1_pubkey_btc(sig, sig_len, msg, msg_len, out_pubkey,
&out_pubkey_size);
if (err) return err;

blake2b_state ctx;
blake2b_init(&ctx, BLAKE2B_BLOCK_SIZE);
blake2b_update(&ctx, out_pubkey, out_pubkey_size);
blake2b_final(&ctx, out_pubkey, BLAKE2B_BLOCK_SIZE);

memcpy(output, out_pubkey, AUTH160_SIZE);
*output_len = AUTH160_SIZE;
return err;
}

int generate_sighash_all(uint8_t *msg, size_t msg_len) {
int ret;
uint64_t len = 0;
Expand Down Expand Up @@ -931,12 +908,6 @@ int ckb_verify_identity(CkbIdentityType *id, uint8_t *sig, uint32_t sig_size,
}
return verify_sighash_all(id->id, sig, sig_size, validate_signature_eth,
convert_eth_message_displaying);
} else if (id->flags == IdentityFlagsEos) {
if (sig == NULL || sig_size != SECP256K1_SIGNATURE_SIZE) {
return ERROR_IDENTITY_WRONG_ARGS;
}
return verify_sighash_all(id->id, sig, sig_size, validate_signature_eos,
convert_copy);
} else if (id->flags == IdentityFlagsTron) {
if (sig == NULL || sig_size != SECP256K1_SIGNATURE_SIZE) {
return ERROR_IDENTITY_WRONG_ARGS;
Expand Down
10 changes: 4 additions & 6 deletions tests/omni_lock_rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ 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",
),
];
const BINARIES: &[(&str, &str)] = &[(
"omni_lock",
"eb2ab5fd9a1dab4354a76ee2765e6a9ac2d94d927da39fb72b1691ea523e4613",
)];

fn main() {
let mut bundled = includedir_codegen::start("BUNDLED_CELL");
Expand Down
9 changes: 5 additions & 4 deletions tests/omni_lock_rust/tests/test_omni_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ fn test_dogecoin_err_pubkey() {
assert!(verify_result.is_err())
}

fn test_eos_success(vtype: u8) {
fn test_eos_fail(vtype: u8) {
let mut data_loader = DummyDataLoader::new();

let mut config = TestConfig::new(IDENTITY_FLAGS_EOS, false);
Expand All @@ -627,7 +627,8 @@ fn test_eos_success(vtype: u8) {

verifier.set_debug_printer(debug_printer);
let verify_result = verifier.verify(MAX_CYCLES);
verify_result.expect("pass verification");
assert!(verify_result.is_err());
assert_script_error(verify_result.unwrap_err(), CKB_INVALID_DATA);
}

fn test_eos_err_pubkey(vtype: u8) {
Expand All @@ -651,11 +652,11 @@ fn test_eos_err_pubkey(vtype: u8) {
verifier.set_debug_printer(debug_printer);
let verify_result = verifier.verify(MAX_CYCLES);
assert!(verify_result.is_err());
assert_script_error(verify_result.unwrap_err(), ERROR_PUBKEY_BLAKE160_HASH);
assert_script_error(verify_result.unwrap_err(), CKB_INVALID_DATA);
}

fn test_eos(vtype: u8) {
test_eos_success(vtype);
test_eos_fail(vtype);
test_eos_err_pubkey(vtype)
}

Expand Down