-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1042: use a special 'ByronHybrid' index with range going from 0 to 2^32 r=KtorZ a=KtorZ # Issue Number <!-- Put here a reference to the issue this PR relates to and which requirements it tackles --> #1041 # Overview <!-- Detail in a few bullet points the work accomplished in this PR --> - [x] I have used a special 'ByronHybrid' index with range going from 0 to 2^32 for the address path. # Comments <!-- Additional comments or screenshots to attach if any --> :question: Should we also worry about the account path :question: <!-- Don't forget to: ✓ Self-review your changes to make sure nothing unexpected slipped through ✓ Assign yourself to the PR ✓ Assign one or several reviewer(s) ✓ Once created, link this PR to its corresponding ticket ✓ Acknowledge any changes required to the Wiki --> Co-authored-by: KtorZ <[email protected]>
- Loading branch information
Showing
11 changed files
with
64 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -216,6 +216,10 @@ instance Bounded (Index 'Soft level) where | |
minBound = Index minBound | ||
maxBound = let (Index ix) = minBound @(Index 'Hardened _) in Index (ix - 1) | ||
|
||
instance Bounded (Index 'WholeDomain level) where | ||
minBound = Index minBound | ||
maxBound = Index maxBound | ||
|
||
instance Enum (Index 'Hardened level) where | ||
fromEnum (Index ix) = fromIntegral ix | ||
toEnum ix | ||
|
@@ -232,11 +236,25 @@ instance Enum (Index 'Soft level) where | |
| otherwise = | ||
Index (fromIntegral ix) | ||
|
||
instance Enum (Index 'WholeDomain level) where | ||
fromEnum (Index ix) = fromIntegral ix | ||
toEnum ix | ||
| Index (fromIntegral ix) > maxBound @(Index 'WholeDomain _) = | ||
error "[email protected]: bad argument" | ||
| otherwise = | ||
Index (fromIntegral ix) | ||
|
||
instance Buildable (Index derivationType level) where | ||
build (Index ix) = fromString (show ix) | ||
|
||
-- | Type of derivation that should be used with the given indexes. | ||
data DerivationType = Hardened | Soft | ||
-- | ||
-- In theory, we should only consider two derivation types: soft and hard. | ||
-- | ||
-- However, historically, addresses in Cardano used to be generated across the | ||
-- both soft and hard domain. We therefore introduce a 'WholeDomain' derivation | ||
-- type that is the exact union of `Hardened` and `Soft`. | ||
data DerivationType = Hardened | Soft | WholeDomain | ||
|
||
-- | An interface for doing hard derivations from the root private key | ||
class HardDerivation (key :: Depth -> * -> *) where | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters