ntls-io / nautilus-trusted-compute

Nautilus Trusted Compute
GNU Affero General Public License v3.0
0 stars 3 forks source link

feat: create oracle-node API #18

Closed billguo99 closed 2 years ago

billguo99 commented 2 years ago
billguo99 commented 2 years ago

Tested auth data response with this redeeming transaction manually through postman - https://testnet.algoexplorer.io/tx/OZGIL3VY4TFAC5AOBLSG2WTRYSG5ZC5LCZWQQGEVQUAFCIDLMIOA.

billguo99 commented 2 years ago

Generating a keypair in PKCS#8 (v2) format and save to file: https://briansmith.org/rustdoc/ring/signature/index.html#signing-and-verifying-with-ed25519 https://www.reddit.com/r/rust/comments/an6kue/create_a_ed25519_keypair_and_write_it_to_disk_in/

    // Generate a key pair in PKCS#8 (v2) format and save to file.
    let rng = rand::SystemRandom::new();
    let pkcs8_bytes = Ed25519KeyPair::generate_pkcs8(&rng).unwrap();
    let pkcs8_bytes: &[u8] = pkcs8_bytes.as_ref();

    fs::write("/tmp/pkcs8.der", pkcs8_bytes).expect("Unable to write file");
billguo99 commented 2 years ago

Error handling: anyhow - binary program thiserror - libraries

jdvlio commented 2 years ago

Would it make sense to call the branch feat(oracle-node) rather than feat(blockchain)?

billguo99 commented 2 years ago

Testing: https://docs.google.com/document/d/1-44A0hKwTc247swsJ1XhEHcVA_Ns2zxPhzeXJNTtQgM/edit Redeeming Transaction: https://testnet.algoexplorer.io/tx/CW6D2XRBJ2F6EP532IUD3GPGSNS7NF3XLYB3BYPQYHFJDFYMJKWQ

Request (I used Postman) and Response from Oracle Node:

curl --location --request GET '127.0.0.1:8081/auth_data' \
--header 'Content-Type: application/json' \
--data-raw '{
    "txn_id": "CW6D2XRBJ2F6EP532IUD3GPGSNS7NF3XLYB3BYPQYHFJDFYMJKWQ",
    "asset_id": 96492563
}'
{
    "auth_data": "eyJyZWRlZW1lZCI6dHJ1ZSwiZHJ0X2NyZWF0b3IiOiJGWDRSQVJTM1BHVURHWEYyT1VUS1VNVFJUT1dJMzI3N1VHSUtJTkg0S1JFR0hKVEhNSkZSWUJJUDJFIiwiZHJ0X3JlZGVlbWVyIjoiNDRPWkZRS1Q2VlNBRUtERzQzVUE0TFQ2TllIVFZWNk5CSU5PU0dCR01LU1ZBUkFUNEJSUUxZQ0dBNCIsImJpbmFyeSI6WzEsMSwxLDEsMSwxLDEsMSwxLDEsMSwxLDEsMSwxLDEsMSwxLDEsMSwxLDEsMSwxLDEsMSwxLDEsMSwxLDEsMV0sImRhdGFfcGFja2FnZSI6WzIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMl0sImJpbmFyeV91cmwiOiJodHRwczovL2hvc3QxLmV4YW1wbGUiLCJkYXRhX3VybCI6Imh0dHBzOi8vaG9zdDIuZXhhbXBsZSJ9",
    "signature": "qtFOoz1O9fLxdQ14cbpp5Wrmo2jIf47z6luUkUAGQE5p/64IYyFgjba2Lcwng4D5gA3Z1LH4qEihmJZHJXIrDg=="
}