Cypherock internship tasks using trezor-firmware

Posted on Dec 25, 2020


Task 1 : To implement Shamir Secret Sharing Alogithm using C.

task 1

Task 2 : To understand how Make works and then calculate a BIP39 Seed using 24 bip mnemonics.

task 2

Task 3 : To derive public key, private key, chain node and reciever-change address for Bitcoin Testnet for derivation path m/44’/1’/0’/0/

  • Derive address from public and private from mnemonics
  • The first node derived is the master node
  • For master node the index is 0000000
  • For purpose node we have to passed index as 8000002C
  • For coin => index => 8000001 (testnet)
  • For account node => 00000000
  • Chain node :
    • 00000001 (change address node)
    • 00000000 (recieve address node)

task 3

Task 4 : To sign an unsigned bitcoin testnet transaction

  • Generate unsigned trans using extendended public key of account node
  • complete byte_array_to_unsigned_txn() to fill the unsigned txn struct 2.1 Use malloc for input and ouput struct inside unsigned_strcut
  • Complete serialize_unsigned_txn_to_sign() func to generate the serializes unsigned txn to sign corresponding to an input
  • Use sha256_raw to generate double hash of the serialize unsigned transation (call the func twice .) (next time kind of recusrive)
  • Use ecdsa_sign_digest() to genrate R and S value using private key corresonding to the input (88thline)
  • Generate script_sig using ecdsa_sig_to_der() (klmoney article)
  • Replace script sig with the script public key for rach input inside the unsigned txn key
  • to fill the signed txn strcut (70 line)

task 4

Task 5 : To sign a raw Ethereum (Ropsten) transaction

  • Search for how ethereum address is generated from public key
  • Convert signed txn from my ether wallet to unsigned txn
  • Code for RLP encoding
  • Hash the unsigned txn
  • Sign the digest using the private key
  • Generate V using
  • Create RLP encoded signed txn from the derived R and S values
  • Broadcast the signed txn using ethers scan
Transcation Details :
  "nonce": "0x02",
  "gasLimit": "0x5208",
  "gasPrice": "0x77359400",
  "to": "0xc0095a58489ba23cb5c6808dc0bbbf1cdca32aca",
  "value": "2c68af0bb140000",
  "data": "0x",
  "chainId": 3

task 5

Resources :