mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-26 01:18:28 +00:00
commit
5ec72d3a5b
@ -8,7 +8,7 @@ These include:
|
||||
- Big Number (256 bit) Arithmetics
|
||||
- BIP32 Hierarchical Deterministic Wallets
|
||||
- BIP39 Mnemonic code
|
||||
- ECDSA signing/verifying (only hardcoded secp256k1 curve,
|
||||
- ECDSA signing/verifying (supports secp256k1 and nist256p1 curves,
|
||||
uses RFC6979 for deterministic signatures)
|
||||
- ECDSA public key derivation + Base58 address representation
|
||||
- HMAC-SHA256 and HMAC-SHA512
|
||||
|
3
bignum.c
3
bignum.c
@ -25,7 +25,6 @@
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include "bignum.h"
|
||||
#include "secp256k1.h"
|
||||
#include "macros.h"
|
||||
|
||||
inline uint32_t read_be(const uint8_t *data)
|
||||
@ -364,7 +363,7 @@ void bn_inverse(bignum256 *x, const bignum256 *prime)
|
||||
// res = old(x)^((prime-2) % 2^(i*30))
|
||||
// get the i-th limb of prime - 2
|
||||
limb = prime->val[i];
|
||||
// this is not enough in general but fine for secp256k1 because prime->val[0] > 1
|
||||
// this is not enough in general but fine for secp256k1 & nist256p1 because prime->val[0] > 1
|
||||
if (i == 0) limb -= 2;
|
||||
for (j = 0; j < 30; j++) {
|
||||
// invariants:
|
||||
|
@ -4,7 +4,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
TARGET = gui
|
||||
TEMPLATE = app
|
||||
|
||||
SOURCES += ../bip32.c ../bip39.c ../sha2.c ../pbkdf2.c ../hmac.c ../rand.c ../bignum.c ../ecdsa.c ../ripemd160.c ../base58.c ../secp256k1.c mainwindow.cpp main.cpp
|
||||
SOURCES += ../bip32.c ../bip39.c ../sha2.c ../pbkdf2.c ../hmac.c ../rand.c ../bignum.c ../ecdsa.c ../ripemd160.c ../base58.c ../secp256k1.c ../nist256p1.c mainwindow.cpp main.cpp
|
||||
|
||||
HEADERS += mainwindow.h ../bip32.h ../bip39.h
|
||||
|
||||
|
@ -45,7 +45,8 @@ void MainWindow::on_spinAccount_valueChanged(int arg1)
|
||||
{
|
||||
if (!root_set) return;
|
||||
const char addr_version = 0x00, wif_version = 0x80;
|
||||
char buf[128];
|
||||
const size_t buflen = 128;
|
||||
char buf[buflen + 1];
|
||||
HDNode node;
|
||||
// external chain
|
||||
for (int chain = 0; chain < 2; chain++) {
|
||||
@ -54,14 +55,14 @@ void MainWindow::on_spinAccount_valueChanged(int arg1)
|
||||
hdnode_private_ckd(&node, 44 | 0x80000000);
|
||||
hdnode_private_ckd(&node, 0 | 0x80000000); // bitcoin
|
||||
hdnode_private_ckd(&node, (arg1 - 1) | 0x80000000);
|
||||
hdnode_serialize_private(&node, buf); QString xprv = QString(buf); ui->lineXprv->setText(xprv);
|
||||
hdnode_serialize_public(&node, buf); QString xpub = QString(buf); ui->lineXpub->setText(xpub);
|
||||
hdnode_serialize_private(&node, buf, buflen); QString xprv = QString(buf); ui->lineXprv->setText(xprv);
|
||||
hdnode_serialize_public(&node, buf, buflen); QString xpub = QString(buf); ui->lineXpub->setText(xpub);
|
||||
hdnode_private_ckd(&node, chain); // external / internal
|
||||
for (int i = 0; i < 100; i++) {
|
||||
HDNode node2 = node;
|
||||
hdnode_private_ckd(&node2, i);
|
||||
ecdsa_get_address(node2.public_key, addr_version, buf); QString address = QString(buf);
|
||||
ecdsa_get_wif(node2.private_key, wif_version, buf); QString wif = QString(buf);
|
||||
ecdsa_get_address(node2.public_key, addr_version, buf, buflen); QString address = QString(buf);
|
||||
ecdsa_get_wif(node2.private_key, wif_version, buf, buflen); QString wif = QString(buf);
|
||||
list->setItem(i, 0, new QTableWidgetItem(address));
|
||||
list->setItem(i, 1, new QTableWidgetItem(wif));
|
||||
list->setItem(i, 2, new QTableWidgetItem("0.0"));
|
||||
|
@ -2,13 +2,12 @@
|
||||
#include <assert.h>
|
||||
#include "bignum.h"
|
||||
#include "ecdsa.h"
|
||||
#include "secp256k1.h"
|
||||
#include "rand.h"
|
||||
|
||||
/*
|
||||
* This program prints the contents of the secp256k1_cp array.
|
||||
* The entry secp256k1_cp[i][j] contains the number (2*j+1)*16^i*G,
|
||||
* where G is the generator of secp256k1.
|
||||
* This program prints the contents of the ecdsa_curve.cp array.
|
||||
* The entry cp[i][j] contains the number (2*j+1)*16^i*G,
|
||||
* where G is the generator of the specified elliptic curve.
|
||||
*/
|
||||
int main(int argc, char **argv) {
|
||||
int i,j,k;
|
||||
|
Loading…
Reference in New Issue
Block a user