Adjust indexing of Sapling payment addresses
This commit is contained in:
parent
8d437105c9
commit
5db66dcf39
2 changed files with 11 additions and 3 deletions
|
@ -103,7 +103,7 @@ genSaplingSpendingKey seed i = do
|
|||
where
|
||||
res =
|
||||
withPureBorshVarBuffer
|
||||
(rustWrapperSaplingSpendingkey seed (fromIntegral i))
|
||||
(rustWrapperSaplingSpendingkey seed (fromIntegral (i + 2 ^ 31)))
|
||||
|
||||
-- | Attempts to generate a sapling Payment Address using an ExtendedSpendingKey and a Diversifier Index
|
||||
genSaplingPaymentAddress :: SaplingSpendingKey -> Int -> Maybe SaplingReceiver
|
||||
|
@ -114,7 +114,7 @@ genSaplingPaymentAddress extspk i =
|
|||
where
|
||||
res =
|
||||
withPureBorshVarBuffer
|
||||
(rustWrapperSaplingPaymentAddress extspk (fromIntegral i))
|
||||
(rustWrapperSaplingPaymentAddress extspk (fromIntegral (i * 111)))
|
||||
|
||||
-- | Generate an internal Sapling address
|
||||
genSaplingInternalAddress :: SaplingSpendingKey -> Maybe SaplingInternalReceiver
|
||||
|
|
10
test/Spec.hs
10
test/Spec.hs
|
@ -476,12 +476,14 @@ main = do
|
|||
property $ prop_SaplingSpendingKey s
|
||||
it "Sapling receivers are valid" $ \s ->
|
||||
property $ prop_SaplingReceiver s
|
||||
it "Sapling receivers are not the same" $ \s ->
|
||||
it "Sapling receivers are distinct" $ \s ->
|
||||
property $ prop_SaplingRecRepeated s
|
||||
it "Orchard spending keys are valid" $ \s ->
|
||||
property $ prop_OrchardSpendingKey s
|
||||
it "Orchard receivers are valid" $ \s ->
|
||||
property $ prop_OrchardReceiver s
|
||||
it "Orchard receivers are distinct" $ \s ->
|
||||
property $ prop_OrchardRecRepeated s
|
||||
describe "Address tests" $ do
|
||||
it "Encode transparent" $ do
|
||||
let ua =
|
||||
|
@ -625,6 +627,12 @@ prop_SaplingRecRepeated s (NonNegative i) =
|
|||
genSaplingPaymentAddress (fromMaybe "" $ genSaplingSpendingKey s 1) i =/=
|
||||
genSaplingPaymentAddress (fromMaybe "" $ genSaplingSpendingKey s 1) (i + 1)
|
||||
|
||||
prop_OrchardRecRepeated ::
|
||||
Seed -> CoinType -> NonNegative Int -> NonNegative Int -> Property
|
||||
prop_OrchardRecRepeated s c (NonNegative i) (NonNegative j) =
|
||||
genOrchardReceiver j (fromMaybe "" $ genOrchardSpendingKey s c i) =/=
|
||||
genOrchardReceiver (j + 1) (fromMaybe "" $ genOrchardSpendingKey s c i)
|
||||
|
||||
-- | Generators
|
||||
genOrcArgs :: Gen (CoinType, Int, Int)
|
||||
genOrcArgs = do
|
||||
|
|
Loading…
Reference in a new issue