Skip to content

Commit b0d1202

Browse files
Merge pull request #88 from IntersectMBO/refactor/bytes
refactor/bytes
2 parents daf98d0 + 31262b5 commit b0d1202

File tree

239 files changed

+697
-2422
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

239 files changed

+697
-2422
lines changed

.changeset/cold-cows-bake.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
"@evolution-sdk/evolution": minor
3+
---
4+
5+
Add CIP-30 message signing support with modular architecture
6+
7+
This release introduces comprehensive CIP-30 `signData` and `verifyData` support, implementing the complete COSE Sign1 specification with a clean, modular structure:
8+
9+
**New Features:**
10+
- Full CIP-30 message signing (`signData`) and verification (`verifyData`) implementation
11+
- COSE (CBOR Object Signing and Encryption) primitives per RFC 8152
12+
- Support for Ed25519 signatures with proper COSE key structures
13+
- Message hashing with BLAKE2b-256 for payload integrity
14+
- CIP-8 compliant address field handling
15+
- Complete test coverage with CSL compatibility tests
16+
17+
**Module Structure:**
18+
- `message-signing/SignData.ts` - Main CIP-30 signData/verifyData API
19+
- `message-signing/Header.ts` - COSE header structures and operations
20+
- `message-signing/Label.ts` - COSE label types and algorithm identifiers
21+
- `message-signing/CoseSign1.ts` - COSE_Sign1 structure implementation
22+
- `message-signing/CoseKey.ts` - COSE key format support
23+
- `message-signing/Ed25519Key.ts` - Ed25519 key operations
24+
- `message-signing/Utils.ts` - Encoding and conversion utilities
25+
26+
**Breaking Changes:**
27+
- Refactored `Bytes` module API:
28+
- Renamed `bytesEquals` to `equals` with stricter type signature (no longer accepts undefined)
29+
- Removed `Bytes.FromHex` schema in favor of Effect's built-in `Schema.Uint8ArrayFromHex`
30+
- Updated `fromHex`/`toHex` to use Effect's native schemas
31+
32+
**Internal Improvements:**
33+
- Removed unused `Bytes` imports across 32 files
34+
- Updated all modules to use new Bytes API
35+
- Improved CBOR encoding/decoding with proper codec options
36+
- Enhanced type safety with Effect Schema compositions

docs/content/docs/modules/core/Address.mdx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Handles both BaseAddress (57 bytes) and EnterpriseAddress (29 bytes)
147147

148148
```ts
149149
export declare const FromBytes: Schema.transformOrFail<
150-
Schema.Union<[Schema.filter<typeof Schema.Uint8ArrayFromSelf>, Schema.filter<typeof Schema.Uint8ArrayFromSelf>]>,
150+
Schema.Union<[Schema.SchemaClass<Uint8Array, Uint8Array, never>, Schema.SchemaClass<Uint8Array, Uint8Array, never>]>,
151151
Schema.SchemaClass<Address, Address, never>,
152152
never
153153
>
@@ -163,9 +163,11 @@ Transform from hex string to AddressStructure
163163

164164
```ts
165165
export declare const FromHex: Schema.transform<
166-
Schema.transform<Schema.Schema<string, string, never>, Schema.Schema<Uint8Array, Uint8Array, never>>,
166+
Schema.Schema<Uint8Array, string, never>,
167167
Schema.transformOrFail<
168-
Schema.Union<[Schema.filter<typeof Schema.Uint8ArrayFromSelf>, Schema.filter<typeof Schema.Uint8ArrayFromSelf>]>,
168+
Schema.Union<
169+
[Schema.SchemaClass<Uint8Array, Uint8Array, never>, Schema.SchemaClass<Uint8Array, Uint8Array, never>]
170+
>,
169171
Schema.SchemaClass<Address, Address, never>,
170172
never
171173
>
@@ -219,7 +221,7 @@ Added in v1.0.0
219221
**Signature**
220222

221223
```ts
222-
export declare const fromBytes: (i: any, overrideOptions?: ParseOptions) => Address
224+
export declare const fromBytes: (i: Uint8Array, overrideOptions?: ParseOptions) => Address
223225
```
224226

225227
## fromHex
@@ -243,7 +245,7 @@ export declare const toBech32: (a: Address, overrideOptions?: ParseOptions) => s
243245
**Signature**
244246

245247
```ts
246-
export declare const toBytes: (a: Address, overrideOptions?: ParseOptions) => any
248+
export declare const toBytes: (a: Address, overrideOptions?: ParseOptions) => Uint8Array
247249
```
248250

249251
## toHex

docs/content/docs/modules/core/AddressEras.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ Schema for encoding/decoding addresses as hex strings.
275275
276276
```ts
277277
export declare const FromHex: Schema.transform<
278-
Schema.transform<Schema.Schema<string, string, never>, Schema.Schema<Uint8Array, Uint8Array, never>>,
278+
Schema.Schema<Uint8Array, string, never>,
279279
Schema.transformOrFail<
280280
typeof Schema.Uint8ArrayFromSelf,
281281
Schema.SchemaClass<

docs/content/docs/modules/core/Anchor.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ CBOR hex transformation schema for Anchor.
191191
export declare const FromCBORHex: (
192192
options?: CBOR.CodecOptions
193193
) => Schema.transform<
194-
Schema.transform<Schema.Schema<string, string, never>, Schema.Schema<Uint8Array, Uint8Array, never>>,
194+
Schema.Schema<Uint8Array, string, never>,
195195
Schema.transform<
196196
Schema.transformOrFail<
197197
typeof Schema.Uint8ArrayFromSelf,

docs/content/docs/modules/core/Assets.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ CBOR hex transformation schema for Assets.
448448
export declare const FromCBORHex: (
449449
options?: CBOR.CodecOptions
450450
) => Schema.transform<
451-
Schema.transform<Schema.Schema<string, string, never>, Schema.Schema<Uint8Array, Uint8Array, never>>,
451+
Schema.Schema<Uint8Array, string, never>,
452452
Schema.transform<
453453
Schema.transformOrFail<
454454
typeof Schema.Uint8ArrayFromSelf,

docs/content/docs/modules/core/AuxiliaryData.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ Transforms between CBOR hex string and AuxiliaryData using CDDL format.
515515
export declare const FromCBORHex: (
516516
options?: CBOR.CodecOptions
517517
) => Schema.transform<
518-
Schema.transform<Schema.Schema<string, string, never>, Schema.Schema<Uint8Array, Uint8Array, never>>,
518+
Schema.Schema<Uint8Array, string, never>,
519519
Schema.transform<
520520
Schema.transformOrFail<
521521
typeof Schema.Uint8ArrayFromSelf,

docs/content/docs/modules/core/BaseAddress.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Convert a BaseAddress to bytes.
5353
**Signature**
5454
5555
```ts
56-
export declare const toBytes: (data: BaseAddress) => any
56+
export declare const toBytes: (data: BaseAddress) => Uint8Array
5757
```
5858
5959
Added in v2.0.0
@@ -150,7 +150,7 @@ toString(): string
150150

151151
```ts
152152
export declare const FromBytes: Schema.transformOrFail<
153-
Schema.filter<typeof Schema.Uint8ArrayFromSelf>,
153+
Schema.SchemaClass<Uint8Array, Uint8Array, never>,
154154
Schema.SchemaClass<BaseAddress, BaseAddress, never>,
155155
never
156156
>
@@ -162,9 +162,9 @@ export declare const FromBytes: Schema.transformOrFail<
162162

163163
```ts
164164
export declare const FromHex: Schema.transform<
165-
Schema.transform<Schema.Schema<string, string, never>, Schema.Schema<Uint8Array, Uint8Array, never>>,
165+
Schema.Schema<Uint8Array, string, never>,
166166
Schema.transformOrFail<
167-
Schema.filter<typeof Schema.Uint8ArrayFromSelf>,
167+
Schema.SchemaClass<Uint8Array, Uint8Array, never>,
168168
Schema.SchemaClass<BaseAddress, BaseAddress, never>,
169169
never
170170
>

docs/content/docs/modules/core/Bech32.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export declare const FromBytes: (
5454
export declare const FromHex: (
5555
prefix?: string
5656
) => Schema.transform<
57-
Schema.transform<Schema.Schema<string, string, never>, Schema.Schema<Uint8Array, Uint8Array, never>>,
57+
Schema.Schema<Uint8Array, string, never>,
5858
Schema.transformOrFail<typeof Schema.Uint8ArrayFromSelf, typeof Schema.String, never>
5959
>
6060
```

docs/content/docs/modules/core/Bip32PrivateKey.mdx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ Convert a Bip32PrivateKey to raw bytes.
164164
**Signature**
165165
166166
```ts
167-
export declare const toBytes: (a: Bip32PrivateKey, overrideOptions?: ParseOptions) => any
167+
export declare const toBytes: (a: Bip32PrivateKey, overrideOptions?: ParseOptions) => Uint8Array
168168
```
169169
170170
Added in v2.0.0
@@ -204,7 +204,7 @@ Parse a Bip32PrivateKey from raw bytes.
204204
**Signature**
205205

206206
```ts
207-
export declare const fromBytes: (i: any, overrideOptions?: ParseOptions) => Bip32PrivateKey
207+
export declare const fromBytes: (i: Uint8Array, overrideOptions?: ParseOptions) => Bip32PrivateKey
208208
```
209209

210210
Added in v2.0.0
@@ -285,8 +285,8 @@ Schema for transforming between Uint8Array and Bip32PrivateKey.
285285

286286
```ts
287287
export declare const FromBytes: Schema.transform<
288-
Schema.filter<typeof Schema.Uint8ArrayFromSelf>,
289-
typeof Bip32PrivateKey
288+
Schema.SchemaClass<Uint8Array, Uint8Array, never>,
289+
Schema.SchemaClass<Bip32PrivateKey, Bip32PrivateKey, never>
290290
>
291291
```
292292

@@ -300,8 +300,11 @@ Schema for transforming between hex string and Bip32PrivateKey.
300300

301301
```ts
302302
export declare const FromHex: Schema.transform<
303-
Schema.transform<Schema.Schema<string, string, never>, Schema.Schema<Uint8Array, Uint8Array, never>>,
304-
Schema.transform<Schema.filter<typeof Schema.Uint8ArrayFromSelf>, typeof Bip32PrivateKey>
303+
Schema.filter<Schema.Schema<Uint8Array, string, never>>,
304+
Schema.transform<
305+
Schema.SchemaClass<Uint8Array, Uint8Array, never>,
306+
Schema.SchemaClass<Bip32PrivateKey, Bip32PrivateKey, never>
307+
>
305308
>
306309
```
307310

docs/content/docs/modules/core/BootstrapWitness.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Transforms between hex string and BootstrapWitness using CBOR encoding.
130130
export declare const FromCBORHex: (
131131
options?: CBOR.CodecOptions
132132
) => Schema.transform<
133-
Schema.transform<Schema.Schema<string, string, never>, Schema.Schema<Uint8Array, Uint8Array, never>>,
133+
Schema.Schema<Uint8Array, string, never>,
134134
Schema.transform<
135135
Schema.transformOrFail<
136136
typeof Schema.Uint8ArrayFromSelf,

0 commit comments

Comments
 (0)