Commit a5c925b3 authored by Éloïs's avatar Éloïs
Browse files

Merge branch 'oxyde-parse-and-verify-tx' into dev

parents c3a291fa 1ac0c64e
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "addr2line"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072"
dependencies = [
"gimli",
]
[[package]]
name = "adler"
version = "0.2.3"
......@@ -21,12 +30,32 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
[[package]]
name = "backtrace"
version = "0.3.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46254cf2fdcdf1badb5934448c1bcbe046a56537b3987d96c51a7afc5d03f293"
dependencies = [
"addr2line",
"cfg-if",
"libc",
"miniz_oxide",
"object",
"rustc-demangle",
]
[[package]]
name = "base64"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7"
[[package]]
name = "beef"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "474a626a67200bd107d44179bb3d4fc61891172d11696609264589be6a0e6a43"
[[package]]
name = "bincode"
version = "1.2.1"
......@@ -37,6 +66,27 @@ dependencies = [
"serde",
]
[[package]]
name = "block-buffer"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b"
dependencies = [
"block-padding",
"byte-tools",
"byteorder",
"generic-array",
]
[[package]]
name = "block-padding"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5"
dependencies = [
"byte-tools",
]
[[package]]
name = "bs58"
version = "0.3.1"
......@@ -49,6 +99,12 @@ version = "3.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12ae9db68ad7fac5fe51304d20f016c911539251075a214f8e663babefa35187"
[[package]]
name = "byte-tools"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
[[package]]
name = "byteorder"
version = "1.3.4"
......@@ -123,30 +179,97 @@ dependencies = [
"lazy_static",
]
[[package]]
name = "cryptoxide"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da24927b5b899890bcb29205436c957b7892ec3a3fbffce81d710b9611e77778"
[[package]]
name = "cslice"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "697c714f50560202b1f4e2e09cd50a421881c83e9025db75d15f276616f04f40"
[[package]]
name = "digest"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
dependencies = [
"generic-array",
]
[[package]]
name = "dubp-common"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b41d722bf752e5f87d07685aba6df25f69881f9aafa7060fae459e2948d8080"
dependencies = [
"dup-crypto",
"dup-crypto 0.18.0",
"serde",
"serde_json",
"thiserror",
]
[[package]]
name = "dubp-common"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41fbf84c220b013b9ebd30315fb89ce1ce74ad415ca24401fbc2bd264aaa5097"
dependencies = [
"dup-crypto 0.25.0",
"serde",
"serde_json",
"thiserror",
]
[[package]]
name = "dubp-documents"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db28e6dd002d47cb916bc72c0ef02e2daedeb019e2710716fa5c30851fabbbca"
dependencies = [
"beef",
"dubp-wallet",
"log",
"serde",
"serde_json",
"thiserror",
]
[[package]]
name = "dubp-documents-parser"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf34add60e4c075265ef74bebebd3fd665f73eaec36133e8bb2fe8aef968a9fc"
dependencies = [
"dubp-documents",
"json-pest-parser",
"pest",
"pest_derive",
"serde_json",
"thiserror",
]
[[package]]
name = "dubp-wallet"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe42d477e61d1f94ce759f1936b9542a7e96acd4de68002289a5fc97c9dc5f36"
dependencies = [
"dubp-common 0.25.0",
"serde",
"smallvec",
"thiserror",
]
[[package]]
name = "dubp-wot"
version = "0.11.0"
dependencies = [
"bincode",
"dubp-common",
"dubp-common 0.2.0",
"log",
"rayon",
"serde",
......@@ -154,15 +277,20 @@ dependencies = [
[[package]]
name = "duniteroxyde"
version = "0.2.9"
version = "0.3.0"
dependencies = [
"bincode",
"bs58",
"dubp-common",
"dubp-common 0.25.0",
"dubp-documents",
"dubp-documents-parser",
"dubp-wallet",
"dubp-wot",
"flate2",
"neon",
"neon-build",
"neon-serde",
"unwrap",
]
[[package]]
......@@ -181,12 +309,45 @@ dependencies = [
"zeroize",
]
[[package]]
name = "dup-crypto"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "287b23c4281016278b47b80baf67186ce756dde738070cc7a41297da5e81dec1"
dependencies = [
"base64",
"bs58",
"byteorder",
"cryptoxide",
"getrandom",
"ring",
"serde",
"thiserror",
"zeroize",
]
[[package]]
name = "either"
version = "1.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
[[package]]
name = "error-chain"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc"
dependencies = [
"backtrace",
"version_check",
]
[[package]]
name = "fake-simd"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
[[package]]
name = "flate2"
version = "1.0.17"
......@@ -199,6 +360,33 @@ dependencies = [
"miniz_oxide",
]
[[package]]
name = "generic-array"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec"
dependencies = [
"typenum",
]
[[package]]
name = "getrandom"
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6"
dependencies = [
"cfg-if",
"libc",
"wasi",
"wasm-bindgen",
]
[[package]]
name = "gimli"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724"
[[package]]
name = "hermit-abi"
version = "0.1.12"
......@@ -223,6 +411,18 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "json-pest-parser"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3bc5c84a2bceeda1ce3bd58497bde2d8cba61ca0b45873ef502401f0ff2ae8ed"
dependencies = [
"pest",
"pest_derive",
"thiserror",
"unwrap",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
......@@ -244,6 +444,12 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "maplit"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
[[package]]
name = "maybe-uninit"
version = "2.0.0"
......@@ -306,6 +512,19 @@ dependencies = [
"neon-sys",
]
[[package]]
name = "neon-serde"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f134307714cdd478581fd3cc990202ead78744d676d8437bdff64260395eb8e"
dependencies = [
"error-chain",
"neon",
"neon-runtime",
"num",
"serde",
]
[[package]]
name = "neon-sys"
version = "0.4.0"
......@@ -316,6 +535,70 @@ dependencies = [
"regex",
]
[[package]]
name = "num"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8536030f9fea7127f841b45bb6243b27255787fb4eb83958aa1ef9d2fdc0c36"
dependencies = [
"num-complex",
"num-integer",
"num-iter",
"num-rational",
"num-traits",
]
[[package]]
name = "num-complex"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95"
dependencies = [
"autocfg",
"num-traits",
]
[[package]]
name = "num-integer"
version = "0.1.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b"
dependencies = [
"autocfg",
"num-traits",
]
[[package]]
name = "num-iter"
version = "0.1.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a6e6b7c748f995c4c29c5f5ae0248536e04a5739927c74ec0fa564805094b9f"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-rational"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611"
dependencies = [
"autocfg",
]
[[package]]
name = "num_cpus"
version = "1.13.0"
......@@ -326,6 +609,67 @@ dependencies = [
"libc",
]
[[package]]
name = "object"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5"
[[package]]
name = "once_cell"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad"
[[package]]
name = "opaque-debug"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
[[package]]
name = "pest"
version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53"
dependencies = [
"ucd-trie",
]
[[package]]
name = "pest_derive"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0"
dependencies = [
"pest",
"pest_generator",
]
[[package]]
name = "pest_generator"
version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55"
dependencies = [
"pest",
"pest_meta",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "pest_meta"
version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d"
dependencies = [
"maplit",
"pest",
"sha-1",
]
[[package]]
name = "proc-macro2"
version = "1.0.19"
......@@ -388,19 +732,25 @@ checksum = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae"
[[package]]
name = "ring"
version = "0.16.12"
version = "0.16.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ba5a8ec64ee89a76c98c549af81ff14813df09c3e6dc4766c3856da48597a0c"
checksum = "952cd6b98c85bbc30efa1ba5783b8abf12fec8b3287ffa52605b9432313e34e4"
dependencies = [
"cc",
"lazy_static",
"libc",
"once_cell",
"spin",
"untrusted",
"web-sys",
"winapi",
]
[[package]]
name = "rustc-demangle"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
[[package]]
name = "ryu"
version = "1.0.5"
......@@ -459,6 +809,27 @@ dependencies = [
"serde",
]
[[package]]
name = "sha-1"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df"
dependencies = [
"block-buffer",
"digest",
"fake-simd",
"opaque-debug",
]
[[package]]
name = "smallvec"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252"
dependencies = [
"serde",
]
[[package]]
name = "spin"
version = "0.5.2"
......@@ -517,6 +888,18 @@ dependencies = [
"lazy_static",
]
[[package]]
name = "typenum"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33"
[[package]]
name = "ucd-trie"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
[[package]]
name = "unicode-xid"
version = "0.2.0"
......@@ -525,9 +908,9 @@ checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
[[package]]
name = "untrusted"
version = "0.7.0"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60369ef7a31de49bcb3f6ca728d4ba7300d9a1658f94c727d4cab8c8d9f4aece"
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
[[package]]
name = "unwrap"
......@@ -535,6 +918,18 @@ version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e33648dd74328e622c7be51f3b40a303c63f93e6fa5f08778b6203a4c25c20f"
[[package]]
name = "version_check"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
[[package]]
name = "wasi"
version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
[[package]]
name = "wasm-bindgen"
version = "0.2.60"
......
......@@ -6,3 +6,6 @@ members = [
[patch.crates-io]
#dubp-common = { path = "../dubp-rs-libs/common" }
#dubp-documents = { path = "../dubp-rs-libs/documents" }
#dubp-documents-parser = { path = "../dubp-rs-libs/documents-parser" }
#dubp-wallet = { path = "../dubp-rs-libs/wallet" }
......@@ -23,7 +23,7 @@ const SIGNATURE = "[A-Za-z0-9+\\/=]{87,88}";
const USER_ID = "[A-Za-z0-9_-]{2,100}";
const INTEGER = "(0|[1-9]\\d{0,18})";
const FINGERPRINT = "[A-F0-9]{64}";
const BLOCK_VERSION = "(10|11|12)";
const BLOCK_VERSION = "(1[0-3])";
const TX_VERSION = "(10)";
const DIVIDEND = "[1-9][0-9]{0,5}";
const ZERO_OR_POSITIVE_INT = "0|[1-9][0-9]{0,18}";
......
......@@ -14,6 +14,7 @@
import { hashf } from "../common";
import { Cloneable } from "./Cloneable";
import { verify } from "../../../neon/lib";
import { TransactionDTOV10 } from "../../../neon/native";
export interface BaseDTO {
base: number;
......@@ -252,7 +253,7 @@ export class TransactionDTO implements Cloneable {
};
}
getTransactionSigResult(dubp_version: number) {
getTransactionSigResult() {
const sigResult = new TxSignatureResultImpl(this.issuers.slice());
let i = 0;
const raw = this.getRawTxNoSig();
......@@ -260,20 +261,15 @@ export class TransactionDTO implements Cloneable {
while (matching && i < this.signatures.length) {
const sig = this.signatures[i];
const pub = this.issuers[i];
if (dubp_version >= 12) {
sigResult.sigs[i].ok = verify(raw, sig, pub);
} else {
// TODO ESZ list all invalid transactions
sigResult.sigs[i].ok = verify(raw, sig, pub);
}
sigResult.sigs[i].ok = verify(raw, sig, pub);
matching = sigResult.sigs[i].ok;
i++;
}
return sigResult;
}
checkSignatures(dubp_version: number) {
return this.getTransactionSigResult(dubp_version).allMatching;
checkSignatures() {
return this.getTransactionSigResult().allMatching;
}
static fromJSONObject(obj: any, currency: string = "") {
......@@ -293,6 +289,23 @@ export class TransactionDTO implements Cloneable {
);
}
static fromTransactionDTOV10(txV10: TransactionDTOV10) {
return new TransactionDTO(
10,
txV10.currency || "",
txV10.locktime || 0,
txV10.hash || "",
txV10.blockstamp || "",
txV10.blockstampTime || 0,
txV10.issuers || [],
txV10.inputs || [],
txV10.outputs || [],
txV10.unlocks || [],
txV10.signatures || [],
txV10.comment || ""
);
}
static toRAW(json: TransactionDTO, noSig = false) {
let raw = "";