Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Problem (Fix #1457): No mock mode for developing on non-sgx platform #1458

Merged
merged 1 commit into from
Apr 23, 2020

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented Apr 21, 2020

Solution:

  • Add mock mode

The basic idea is described in #1457.

Copy link
Collaborator

@leejw51crypto leejw51crypto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@devashishdxt
Copy link
Collaborator

bors try

bors bot added a commit that referenced this pull request Apr 22, 2020
@bors
Copy link
Contributor

bors bot commented Apr 22, 2020

try

Build succeeded:

@yihuang yihuang force-pushed the mock-tx-query branch 2 times, most recently from e68e57c to a4a7a2f Compare April 22, 2020 07:16
Copy link
Contributor

@tomtau tomtau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as this adds a new path in chain-abci, perhaps bump a version to "0.4.1" + update a changelog (instead of *Unreleased* ## v0.5.0 it could be *Unreleased* ## v0.4.1)?

-- or bump to / keep it in v0.5.0 if this goes ahead #1466


const ENCRYPTION_KEY: u8 = 0x0f;
const SEAL_KEY: u8 = 0xf0;
pub fn decryt(payload: &TxObfuscated) -> PlainTxAux {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

decrypt?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

decrypt?

Thanks, done.

const SEAL_KEY: u8 = 0xf0;
pub fn decryt(payload: &TxObfuscated) -> PlainTxAux {
let unpad = unpad_payload(&payload.txpayload);
let bs = unpad.iter().map(|b| b ^ ENCRYPTION_KEY).collect::<Vec<_>>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of this custom xor, it could just import and use AEAD + aes-gcm-siv ?

Comment on lines +19 to +22
tx.encode()
.into_iter()
.map(|b| b ^ SEAL_KEY)
.collect::<Vec<_>>()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's now this pure Rust sealing: https://github.com/crypto-com/chain/blob/master/chain-tx-enclave/enclave-utils/src/lib.rs
instead of this custom, it could just produce mock payloads that correspond to the Intel SDK payloads, but it won't be deriving key using the "egetkey" instruction -- it'll just have one hardcoded mock key

Copy link
Collaborator Author

@yihuang yihuang Apr 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that simple xor may be good enough for the mock purpose?
After all, it's only for dev/testing purpose, people should bear in mind that there's always potential false positive and false negatives?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these were just small suggestions -- the main requested change is just updating the changelog; it's ok to merge this without this improved mocking for now

… platform

Solution:
- Add mock mode
- Fix warning of release building, Fix crypto-com#1465
@yihuang
Copy link
Collaborator Author

yihuang commented Apr 22, 2020

as this adds a new path in chain-abci, perhaps bump a version to "0.4.1" + update a changelog (instead of *Unreleased* ## v0.5.0 it could be *Unreleased* ## v0.4.1)?

-- or bump to / keep it in v0.5.0 if this goes ahead #1466

The changelog is added.

@yihuang yihuang requested a review from tomtau April 22, 2020 13:22
@tomtau
Copy link
Contributor

tomtau commented Apr 23, 2020

bors r+

bors bot added a commit that referenced this pull request Apr 23, 2020
1458: Problem (Fix #1457): No mock mode for developing on non-sgx platform r=tomtau a=yihuang

Solution:
- Add mock mode

The basic idea is described in #1457.

Co-authored-by: yihuang <huang@crypto.com>
@bors
Copy link
Contributor

bors bot commented Apr 23, 2020

Build failed:

@yihuang
Copy link
Collaborator Author

yihuang commented Apr 23, 2020

Build failed:

#1475 again.

@tomtau
Copy link
Contributor

tomtau commented Apr 23, 2020

yeah, will be good to resolve #1475 soon

@tomtau
Copy link
Contributor

tomtau commented Apr 23, 2020

bors retry

@bors
Copy link
Contributor

bors bot commented Apr 23, 2020

Build succeeded:

@bors bors bot merged commit 0c9738f into crypto-com:master Apr 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants