Commit Graph

55 Commits

Author SHA1 Message Date
Shreyansh
a58ef1cd02
Storing peers in database (#3773)
* rebase

* fix

* fix

* remove unwanted diffs

* fix

* formatting

* changes from comments

* Revert "changes from comments"

This reverts commit eb8a795718dc590802a19c7ce4cce4501bd2de1f.

* changes from comments

* add PeerManager

* add sha3-256

* add NetworkUtilTest

* formatting
2022-01-09 07:21:59 -06:00
benthecarman
f4a2ec8554
Make AesEncryptedData a network element / factory (#3952) 2021-12-30 06:30:31 -06:00
Chris Stewart
132479d271
Implement ability to provide external entropy to bitcoin-s (#3672)
* Encapsulate initialization of DLCOracle.start() method

* Use internal WalletAppConfig.kmConf rather than passing in custom key manager parameters

* Add KeyManagerAppConfig.defaultAccountType

* Get all tests passing besides TrezorAddressTest

* Get TrezorAddressTest passing with provided entropy

* Add unit test to make sure we can always derive the seed

* Get docs compiling

* Fix dlcWalletTest test cases

* Add more test cases to keymanager

* Add the new configuration to the example configuration

* Add more test cases

* Remove coverage on 2.12 as it isn't accurate

* Rework DLCOracleAppConfig.start() to call kmConf.start() so the oracle can use entropy provided via bitcoin-s.conf
2021-09-18 09:49:11 -05:00
benthecarman
f2a2874177
Add new invalid BIP 32 test vectors (#3634)
* Add new invalid BIP 32 test vectors

* Make sure priv key isn't zero

* Add comments
2021-08-31 07:59:34 -05:00
benthecarman
be8e965367
DLC Wallet pulldown (#3138)
* DLC Wallet pulldown

* Respond to review
2021-05-25 17:31:01 -05:00
Nadav Kohen
745e4c89fa
Removed point multiplication from ECPrivateKey.freshPrivateKey (#3116)
* Removed point multiplication from ECPrivateKey.freshPrivateKey

* Responded to review
2021-05-21 00:46:20 -06:00
Nadav Kohen
ac3bae403b
Pulled down all remaining non-wallet non-gui code on adaptor-dlc (#3101) 2021-05-18 06:29:46 -05:00
Nadav Kohen
6bc0943a62
Call decompression on public keys less (#2988)
* Removed type parameter from PublicKey

* Deduplicated call to public key decompression in isFullyValid

* Fixed FieldElement

* Added CurveCoordinate to replace FieldElement in places where it was being misused

* Added edge case tests
2021-05-07 02:05:10 -05:00
Nadav Kohen
78f4dfb8c6
Pubkey Refactor (#2936)
* Removed ExecutionContext from ECKey

* Refactored ECPublicKey to remove compression state and introduced ECPublicKeyBytes to handle cases where serialization of input is important

* Fixed the rest of bitcoin-s so that it passes all tests

* Made all ECKeys into case classes

* Successfully added isFullyValid invariant to ECPublicKey!

* Fixed docs

* Added scaladocs and fixed a RpcPsbtResult bug

* Reject private keys of length < 32 and fix WIF parsing bug
2021-05-06 13:19:52 -05:00
Nadav Kohen
63a6f9309d
Introduced AsyncAdaptorSign and AdaptorSign traits (#3037) 2021-05-05 09:34:03 -05:00
Nadav Kohen
7fd9aca304 Add Schnorr and Adaptor Secp Bindings and Update Adaptor (#2885)
* Replaced secp256k1 with secp256k1-zkp as submodule pointing to my java-bindings branch

* Built new binaries for schnorr signing and adaptor signing and integrated into LibSecp256k1CryptoRuntime

* Added public key compression function with tests, removed old adaptor signature point serializers

* Implemented ECDSA adaptor signatures in scala according to the most recent spec

* Added static test vectors for adaptor signing from spec

* Moved bouncy castle adaptor signing tests to .jvm

* Added scaladocs and responded to nits

* Added scaladocs with legends to spec naming

* Responded to Ben's review

* Fixed scala 2.12 compile issue

* Fixed BouncyCastle secKeyVerify

* Updated add-to-jni build instructions

* Updated secp256k1-zkp to target bitcoin-s-master

* Add windows binary (#14)

* Added Mac OS binaries

Co-authored-by: benthecarman <benthecarman@live.com>
2021-04-21 09:42:43 -05:00
benthecarman
fa80f36d2f Get all of Core working with JS (#2826)
* core-test-js-json

* Add SigPointComputer cross compile
Co-authored-by: Nadav Kohen <nadavk25@gmail.com>

* Fix java.time for scalajs

* InetAddress for scalajs

* Fix linking errors in coreTestJS

* Easy fixes

* InetAddress Tests

* Update micropickle, fix exact functions

* Get BigSizeUIntTest working with upickle

* Fix exact funcs

* Update Base58Test with upickle

* Update ScriptSignatureTest with upickle

* Update TransactionTest with upickle

* Update BlockFilterTest with upickle

* Update ScriptInterpreterTest with upickle

* Update MnemonicCodeTest with upickle

* Add InetAddress unit tests

* Fix compile errors

* Get core tests running, not passing

* Sign with js

* Fix PSBTUnitTest

* Fix PBKDF2 for JS

* Use bcrypto's secp256k1 instead of ecdsa

* Fix 2.12.12 compile

* Core tests passing :)

* Test corejs
2021-03-31 15:04:30 -05:00
Chris Stewart
c2409b46c4 Silence scalajs warnings for org.bitcoins.crypto package (#2822)
* Silence scalajs warnings for org.bitcoins.crypto package

* Add comments

* Create 'facades' package, move all js facades into that package. Make the new -Wconf flags work with only scala 2.13.x

* Small cleanups
2021-03-28 08:28:21 -05:00
Nadav Kohen
e6899b20b1 Made ECPrivateKey signing synchronous and got src compiling (#2652)
Fixed tests

De-futured tx buidling, finalizing and signing

Responded to review
2021-03-23 17:05:58 -05:00
rorp
85f6ee889c Adaptor signatures for Scala.js (#2794)
* Schnorr sigs for Scala.js

* fix build

* put BIP340 test vectors in a shared space

* remove teskit dependency, fix point edge cases

* fix build

* Adaptor signatures for Scala.jsr

* add some more tests

* add unit tests for point addition

* scaladoc

* add more public keys tests

* Add scaladoc

* Remove extra isCompressed flag on CryptoRuntime.toPublicKey() as it is inside of ECPrivateKey already

Co-authored-by: christewart <stewart.chris1234@gmail.com>
2021-03-22 16:50:04 -05:00
rorp
911fca5825 Schnorr js (#2805)
* Schnorr sigs for Scala.js

* fix build

* put BIP340 test vectors in a shared space

* remove teskit dependency, fix point edge cases

* fix build

* add unit tests for point addition

* scaladoc

* cleanup

* respond to the comments

* Fix usage of BitcoinSLogger

Co-authored-by: christewart <stewart.chris1234@gmail.com>
2021-03-22 12:56:40 -05:00
Chris Stewart
78448b277c Revert "Schnorr sigs for Scala.js (#2784)" (#2802)
This reverts commit 8e7bde0ed9.
2021-03-16 13:19:16 -05:00
rorp
8e7bde0ed9 Schnorr sigs for Scala.js (#2784) 2021-03-16 10:21:47 -07:00
rorp
7e23eecb20 SipHash for Scala.js (#2797) 2021-03-16 09:43:50 -05:00
Chris Stewart
7245eb0ec9 Update all deps that failed because of bad build (#2774)
* Update all deps that failed because of bad build

* Revert jvmopts

* Try bumping jvmopts max heap size to get mac builds to work

* Double up timeout in ScriptGenerators

* Use Future.successful() in signFunction to try and reduce overload on executionContext

* Push to github to force re-run of CI

* Upgrade sbt to 1.4.9
2021-03-10 06:48:21 -06:00
rorp
5a2f95c38e WIP: Implement bcrypto facades (#2743)
* Implement bcrypto facades

* signatures

* some more facades

* move JS test

* move JVM tests

* CryptoUtilTest

* CI config

* fix CI config

* add npm dependencies

* test over fullLinkJS-generated files
2021-03-05 07:21:39 -06:00
Chris Stewart
5ba7b553b0 2021 02 27 dersignatureutil mv (#2730)
* Move CryptoParams to shared crypto project, make BouncyCastleCryptoParams for bouncy castle specific things

* Rework build structure to work better with scalajs

* Add unit test to make sure CryptoParams & BouncyCastleCryptoParams are consistent
2021-02-28 07:09:22 -06:00
rorp
c90f318fd7 Refactor crypto module to be compatible with Scala.js part 1 (#2719)
* Refactor crypto module to be compatible with Scala.js

* more changes

* some more changes

* abstract out Schnorr stuff

* abstract out adapter stuff

* cleanup

* some more cleanup

* fix build

* Removed references to ECPoint outside of .jvm scope

* remove references to ECPoint from the shared code

* cleanup

* remove cirlular dependencies

* more cleanup

* cleanup

* move SipHash to CryptoContext

* scaladoc

* scalafmt

Co-authored-by: nkohen <nadavk25@gmail.com>
2021-02-27 05:58:20 -06:00
Nadav Kohen
74a30fe9b8 Optimized sigPoint computation to use non-custom secp functions (#2665) 2021-02-16 14:12:38 -06:00
Chris Stewart
b1fc575ff5 CryptoRuntime abstraction (#2658)
* Add CryptoRuntime, extend it with CryptoUtil

* Remove direct usages of CryptoUtil in the core project, use CryptoTrait.cryptoRuntime

* Add JvmCryptoRuntime

* Take ben's suggestion so we don't need to modify anyting in core, h/t to ben

* Refactor ECPrivateKey.freshPrivateKey to use CryptoUtil.freshPrivateKey

* Remove CryptoTrait as it is no longer necessary
2021-02-12 15:18:42 -06:00
Chris Stewart
8f958bf5d9 Update scalafmt (#2619) 2021-02-03 16:37:12 -06:00
Nadav Kohen
93f33d26b6 Update dlc before release (#2543)
* Pulled down DLC data structure work

* Responded to Ben's review

* Gave Vector types names

* Pulled down Chris' work
2021-02-02 08:14:24 -06:00
Chris Stewart
bcfc0d51a8 Commit add Opt/T fromBytes/fromHex methods similar to StringFactory (#2499) 2021-01-09 13:04:07 -06:00
Chris Stewart
4e1a6c69f0 2020 12 18 enable lint options (#2454)
* Enable -Xlint:adapted-args,nullary-unit on our for compile scope

* Add Xlint:infer-any compiler option

* Fix build so test compiler options are actually enabled

* Enable more scalac linting options

* Add '-Xlint:eta-sam'

* Add 'Xlint:inaccessible,Xlint:missing-interpolator'
2021-01-03 08:01:26 -06:00
Nadav Kohen
e1422ddbc2 Fixed Low R signing (#2408)
* Fixed Low R signing and added a test

* Made separate test for comparing bitcoin-s and bitcoind

* Fixed PSBTUnitTest
2020-12-21 14:50:34 -06:00
Nadav Kohen
f7fdca3e22 DLC Data Structures on Master Cleanup (#2375)
* Moved dlc data structures from commons to core

* Renamed DLC payout curve classes

* Split OutcomeValuePoint up into an ADT

* Added utility for computing Schnorr multiple-signature points

* Replaced tuples in RoundingIntervals with types

* Replaced tuples in DLCPayoutCurve with Indexed

* Fixed a compile bug
2020-12-17 09:09:57 -06:00
Nadav Kohen
b7ffea2525 Pulled down work from adaptor-dlc onto master (#2339)
* Pulled down work from adaptor-dlc onto master

* Reverted some accidental deletions

* Removed unused import

* Added scaladocs

* Responded to Ben's review

* Added some scaladocs and invariants

* Responded to chris' review

* Responded to more review

* Added some comments
2020-12-11 17:32:35 -06:00
Ben Carman
c29b787ab5 Add ability to change aes password (#2254)
* Add ability to change aes password

* Add docs

* Rename, add logs + tests
2020-11-15 08:07:49 -06:00
Ben Carman
9787e89403 Add Wallet State Descriptors (#2157)
* Add Wallet State Descriptors

* Sync blocks while offline w/ bitcoind backend

* Add to WalletDbManagement

* Update db management test

* Respond to review

* Rename function
2020-10-14 14:17:51 -05:00
Nadav Kohen
e71b664e1a Brought down ecdsa adaptor signatures implemented in scala from the dlc-crypto branch (#2034) 2020-10-02 10:43:59 -05:00
Nadav Kohen
4c202fd016 Introduced NFC normalization for strings in CryptoUtil and added String hashing functions (#2102) 2020-10-01 14:37:28 -05:00
Ben Carman
a694ef16b7 Add ability to fully spend utxos (#2063)
* Let RawTxSigner dummy sign transactions

* Add ability to fully spend utxos

* Fix NeutrinoNodeWithWalletTest

* Fix test, simplify call
2020-09-27 08:16:26 -05:00
Nadav Kohen
613f6ba4b9 Updated Bouncy Castle Schnorr implementation to most recent BIP 340 (#2025) 2020-09-16 17:01:30 -05:00
Chris Stewart
43ba2477b5 Cache DoubleSha256Digest.hex (#1932)
* Cache DoubleSha256Digest.hex

* Cache little endian versino too
2020-08-29 07:35:40 -05:00
Chris Stewart
955978f635 Apply string factory to a bunch of easy things (#1891)
* Apply string factory to a bunch of easy things

* Refactor HDPath, ExtKey, and LnTagPrefix to use StringFactory

* Implemen StringFactory on LnHumanReadablePart, ScriptType, ServiceIdentifier

* Implement StringFactory on AesCrypt, NodeUri, AddressTag, PSBT, TxoState

* Fix failing tests, fix website compile

* Apply StringFactory to all ScriptOperations, ChannelState, Script Parsing
2020-08-25 10:48:37 -05:00
Scala Steward
bef9c2648e Update scalafmt-core to 2.6.4 (#1686)
* Update scalafmt-core to 2.6.4

* Format everything

Co-authored-by: Ben Carman <benthecarman@live.com>
2020-08-24 14:24:16 -05:00
Ben Carman
231b692fdf Make ECDigitalSignature extend NetworkElement (#1750) 2020-08-04 07:29:52 -05:00
Nadav Kohen
666d53d94a Add low R signing (#1342)
* Added signing with entropy to the JNI and implemented low R signing

* Added check for determinism of low R signing

* Cleaned up test

* Implemented signing with entropy in Bouncy Castle

* Added docs for signing with entropy

* Fixed things after rebase

* De-parallelized signLowR and added scaladoc warnings to signWithEntropy
2020-07-29 15:03:18 -05:00
Ben Carman
16dd256716 Override correct equals functions (#1621)
* Override correct equals functions

* Remove no longer needed function
2020-07-06 06:37:19 -05:00
Scala Steward
97a4886c6e Update scalafmt-core to 2.6.0 (#1579)
* Update scalafmt-core to 2.6.0

* Upgrade scalafmt, fix all formatting errors

* Scalafmt on 2.12

* fix test

* More fixes

Co-authored-by: Ben Carman <benthecarman@live.com>
2020-06-19 10:38:12 -05:00
Nadav Kohen
baf49b7452 Schnorr Data Structures (#1564)
* Pulled down crypto things from dlc branch including: Schnorr data structures, Schnorr Bouncy Castle implementation, FieldElement, and tests for these things

* Call fromValidHex in CryptoUtil
2020-06-16 09:52:45 -05:00
Chris Stewart
c54d6dcbdc 2020 06 09 addr invoice string factory (#1538)
* Implement StringFactory with Address and LnInvoice

* Address code review

* Run scalafmt
2020-06-11 10:44:12 -05:00
Chris Stewart
5c2fb8f580 Add StringFactory trait (#1537) 2020-06-09 15:03:56 -05:00
Chris Stewart
b036aa3338 Add more optimizations, MultSignatureScriptPubKey.isMultiSignatureScr… (#1475)
* Add more optimizations, MultSignatureScriptPubKey.isMultiSignatureScriptPubKey() fails fast if it's not a valid multisig spk, also use more caching inside of Number's (UInt64, UInt32, etc)

* Fix shortChannelidTest

* Cache popular UInt64 numbers that are used in ScriptPubKey's. This reduces allocations which reduces memory usage
2020-05-27 15:47:20 -05:00
Nadav Kohen
4f2c8f73f1 CryptoContext Refactor (#1469)
* Moved logic to disable use of secp256k1 library into crypto project

* Fixed secp doc
2020-05-26 13:05:21 -05:00