Skip to content

Commit 19aa946

Browse files
committed
minor ecies helper update, merge input optimization branch
1 parent 3654511 commit 19aa946

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

CHANGELOG.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,24 @@ All notable changes to this project will be documented in this file. The format
55
## Table of Contents
66

77
- [Unreleased](#unreleased)
8-
- [1.1.5 - 2024-09-06](#113---2024-09-06)
9-
- [1.1.4 - 2024-09-05](#113---2024-09-05)
8+
- [1.1.6 - 2024-09-09](#116---2024-09-09)
9+
- [1.1.5 - 2024-09-06](#115---2024-09-06)
10+
- [1.1.4 - 2024-09-05](#114---2024-09-05)
1011
- [1.1.3 - 2024-09-04](#113---2024-09-04)
1112
- [1.1.2 - 2024-09-02](#112---2024-09-02)
1213
- [1.1.1 - 2024-08-28](#111---2024-08-28)
1314
- [1.1.0 - 2024-08-19](#110---2024-08-19)
1415
- [1.0.0 - 2024-06-06](#100---2024-06-06)
1516

16-
## [1.1.5] - 2025-09-06
17+
## [1.1.6] - 2024-09-09
18+
- Optimize handling of source transaction inputs. Avoid mocking up entire transaction when adding source inputs.
19+
- Minor alignment in ECIES helper function
20+
21+
### Changed
22+
- `SetSourceTxFromOutput` changed to be `SetSourceTxOutput`
23+
- Default behavior of `EncryptSingle` uses ephemeral key. Updated test.
24+
25+
## [1.1.5] - 2024-09-06
1726
- Add test for ephemeral private key in electrum encrypt ecies
1827
- Add support for compression for backward compatibility and alignment with ts
1928

@@ -23,7 +32,7 @@ All notable changes to this project will be documented in this file. The format
2332

2433
## [1.1.4] - 2024-09-05
2534

26-
- Update ECIES implementation to align with
35+
- Update ECIES implementation to align with the typescript library
2736

2837
### Added
2938
- `primitives/aescbc` directory

compat/ecies/ecies.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func EncryptSingle(message string, privateKey *ec.PrivateKey) (string, error) {
1919
if privateKey == nil {
2020
return "", errors.New("private key is required")
2121
}
22-
decryptedBytes, _ := ElectrumEncrypt(messageBytes, privateKey.PubKey(), privateKey, false)
22+
decryptedBytes, _ := ElectrumEncrypt(messageBytes, privateKey.PubKey(), nil, false)
2323
return base64.StdEncoding.EncodeToString(decryptedBytes), nil
2424
}
2525

compat/ecies/ecies_test.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ func TestEncryptDecryptSingle(t *testing.T) {
2020
// Electrum Encrypt
2121
encryptedData, err := EncryptSingle(msgString, pk)
2222
require.NoError(t, err)
23-
require.Equal(t, "QklFMQO7zpX/GS4XpthCy6/hT38ZKsBGbn8JKMGHOY5ifmaoT890Krt9cIRk/ULXaB5uC08owRICzenFbm31pZGu0gCM2uOxpofwHacKidwZ0Q7aEw==", encryptedData)
2423

2524
// Electrum Decrypt
2625
decryptedData, _ := DecryptSingle(encryptedData, pk)
@@ -133,7 +132,20 @@ func TestElectrumEncryptDecryptWithCounterpartyNoKey(t *testing.T) {
133132
require.Equal(t, msgString, string(decryptedData))
134133
}
135134

136-
func TestBitcoreEncryptDecryptSolo(t *testing.T) {
135+
func TestBitcoreEncryptDecryptSingle(t *testing.T) {
136+
pk, _ := ec.PrivateKeyFromWif(wif)
137+
138+
// Bitcore Encrypt
139+
encryptedData, err := BitcoreEncrypt([]byte(msgString), pk.PubKey(), nil, nil)
140+
require.NoError(t, err)
141+
142+
// Bitcore Decrypt
143+
decryptedData, err := BitcoreDecrypt(encryptedData, pk)
144+
require.NoError(t, err)
145+
require.Equal(t, msgString, string(decryptedData))
146+
}
147+
148+
func TestBitcoreEncryptDecryptSingleWithPrivateKey(t *testing.T) {
137149
expectedEncryptedData := "A7vOlf8ZLhem2ELLr+FPfxkqwEZufwkowYc5jmJ+ZqhPAAAAAAAAAAAAAAAAAAAAAB27kUY/HpNbiwhYSpEoEZZDW+wEjMmPNcAAxnc0kiuQ73FpFzf6p6afe4wwVtKAAg=="
138150
decodedExpectedEncryptedData, _ := base64.StdEncoding.DecodeString(expectedEncryptedData)
139151
log.Printf("Decoded expected encrypted data: %x\n", decodedExpectedEncryptedData)

0 commit comments

Comments
 (0)