-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Batch 11: ToBytes on EntropyNBytes (#105)
- Loading branch information
1 parent
cdff3ce
commit 6a4e34c
Showing
25 changed files
with
267 additions
and
62 deletions.
There are no files selected for viewing
47 changes: 0 additions & 47 deletions
47
apple/Sources/Sargon/Extensions/Methods/Crypto/Derivation/Mnemonic+Wrap+Functions.swift
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
20 changes: 20 additions & 0 deletions
20
apple/Sources/Sargon/Extensions/Methods/Prelude/Bytes/Entropy16Bytes+Wrap+Functions.swift
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Alexander Cyon on 2024-04-25. | ||
// | ||
|
||
import Foundation | ||
import SargonUniFFI | ||
|
||
extension Entropy16Bytes { | ||
|
||
public init(bytes: some DataProtocol) throws { | ||
self = try newEntropy16BytesFromBytes(bytes: Data(bytes)) | ||
} | ||
|
||
public var data: Data { | ||
entropy16BytesToBytes(bytes: self) | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
apple/Sources/Sargon/Extensions/Methods/Prelude/Bytes/Entropy20Bytes+Wrap+Functions.swift
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Alexander Cyon on 2024-04-25. | ||
// | ||
|
||
import Foundation | ||
import SargonUniFFI | ||
|
||
extension Entropy20Bytes { | ||
|
||
public init(bytes: some DataProtocol) throws { | ||
self = try newEntropy20BytesFromBytes(bytes: Data(bytes)) | ||
} | ||
|
||
public var data: Data { | ||
entropy20BytesToBytes(bytes: self) | ||
} | ||
} | ||
|
12 changes: 12 additions & 0 deletions
12
apple/Sources/Sargon/Extensions/Methods/Prelude/Bytes/Entropy24Bytes+Wrap+Functions.swift
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Foundation | ||
import SargonUniFFI | ||
|
||
extension Entropy24Bytes { | ||
public init(bytes: some DataProtocol) throws { | ||
self = try newEntropy24BytesFromBytes(bytes: Data(bytes)) | ||
} | ||
|
||
public var data: Data { | ||
entropy24BytesToBytes(bytes: self) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
apple/Sources/Sargon/Extensions/Methods/Prelude/Bytes/Entropy28Bytes+Wrap+Functions.swift
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Foundation | ||
import SargonUniFFI | ||
|
||
extension Entropy28Bytes { | ||
public init(bytes: some DataProtocol) throws { | ||
self = try newEntropy28BytesFromBytes(bytes: Data(bytes)) | ||
} | ||
|
||
public var data: Data { | ||
entropy28BytesToBytes(bytes: self) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
apple/Sources/Sargon/Extensions/Methods/Prelude/Bytes/Entropy32Bytes+Wrap+Functions.swift
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Foundation | ||
import SargonUniFFI | ||
|
||
extension Entropy32Bytes { | ||
public init(bytes: some DataProtocol) throws { | ||
self = try newEntropy32BytesFromBytes(bytes: Data(bytes)) | ||
} | ||
|
||
public var data: Data { | ||
entropy32BytesToBytes(bytes: self) | ||
} | ||
} | ||
|
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
8 changes: 8 additions & 0 deletions
8
apple/Sources/Sargon/Extensions/SampleValues/Prelude/Bytes/Entropy16Bytes+SampleValues.swift
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import SargonUniFFI | ||
|
||
#if DEBUG | ||
extension Entropy16Bytes { | ||
public static let sample: Self = newEntropy16BytesSample() | ||
public static let sampleOther: Self = newEntropy16BytesSampleOther() | ||
} | ||
#endif // DEBUG |
8 changes: 8 additions & 0 deletions
8
apple/Sources/Sargon/Extensions/SampleValues/Prelude/Bytes/Entropy20Bytes+SampleValues.swift
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import SargonUniFFI | ||
|
||
#if DEBUG | ||
extension Entropy20Bytes { | ||
public static let sample: Self = newEntropy20BytesSample() | ||
public static let sampleOther: Self = newEntropy20BytesSampleOther() | ||
} | ||
#endif // DEBUG |
8 changes: 8 additions & 0 deletions
8
apple/Sources/Sargon/Extensions/SampleValues/Prelude/Bytes/Entropy24Bytes+SampleValues.swift
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import SargonUniFFI | ||
|
||
#if DEBUG | ||
extension Entropy24Bytes { | ||
public static let sample: Self = newEntropy24BytesSample() | ||
public static let sampleOther: Self = newEntropy24BytesSampleOther() | ||
} | ||
#endif // DEBUG |
8 changes: 8 additions & 0 deletions
8
apple/Sources/Sargon/Extensions/SampleValues/Prelude/Bytes/Entropy28Bytes+SampleValues.swift
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import SargonUniFFI | ||
|
||
#if DEBUG | ||
extension Entropy28Bytes { | ||
public static let sample: Self = newEntropy28BytesSample() | ||
public static let sampleOther: Self = newEntropy28BytesSampleOther() | ||
} | ||
#endif // DEBUG |
8 changes: 8 additions & 0 deletions
8
apple/Sources/Sargon/Extensions/SampleValues/Prelude/Bytes/Entropy32Bytes+SampleValues.swift
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import SargonUniFFI | ||
|
||
#if DEBUG | ||
extension Entropy32Bytes { | ||
public static let sample: Self = newEntropy32BytesSample() | ||
public static let sampleOther: Self = newEntropy32BytesSampleOther() | ||
} | ||
#endif // DEBUG |
4 changes: 4 additions & 0 deletions
4
apple/Sources/Sargon/Extensions/Swiftified/Prelude/Bytes/BIP39Entropy+Swiftified.swift
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import SargonUniFFI | ||
import Foundation | ||
|
||
public typealias BIP39Entropy = Bip39Entropy |
6 changes: 6 additions & 0 deletions
6
apple/Sources/Sargon/Extensions/Swiftified/Prelude/Bytes/Entropy16Bytes+Swiftified.swift
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Foundation | ||
import SargonUniFFI | ||
|
||
extension Entropy16Bytes: ExactlyNBytesProtocol { | ||
public static let length = 16 | ||
} |
6 changes: 6 additions & 0 deletions
6
apple/Sources/Sargon/Extensions/Swiftified/Prelude/Bytes/Entropy20Bytes+Swiftified.swift
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Foundation | ||
import SargonUniFFI | ||
|
||
extension Entropy20Bytes: ExactlyNBytesProtocol { | ||
public static let length = 20 | ||
} |
6 changes: 6 additions & 0 deletions
6
apple/Sources/Sargon/Extensions/Swiftified/Prelude/Bytes/Entropy24Bytes+Swiftified.swift
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Foundation | ||
import SargonUniFFI | ||
|
||
extension Entropy24Bytes: ExactlyNBytesProtocol { | ||
public static let length = 24 | ||
} |
7 changes: 7 additions & 0 deletions
7
apple/Sources/Sargon/Extensions/Swiftified/Prelude/Bytes/Entropy28Bytes+Swiftified.swift
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
import Foundation | ||
import SargonUniFFI | ||
|
||
extension Entropy28Bytes: ExactlyNBytesProtocol { | ||
public static let length = 28 | ||
} |
6 changes: 6 additions & 0 deletions
6
apple/Sources/Sargon/Extensions/Swiftified/Prelude/Bytes/Entropy32Bytes+Swiftified.swift
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Foundation | ||
import SargonUniFFI | ||
|
||
extension Entropy32Bytes: ExactlyNBytesProtocol { | ||
public static let length = 32 | ||
} |
2 changes: 1 addition & 1 deletion
2
apple/Sources/Sargon/Extensions/Swiftified/Profile/Profile+Swiftified.swift
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 |
---|---|---|
@@ -1,3 +1,12 @@ | ||
import SargonUniFFI | ||
import Foundation | ||
|
||
public protocol ExactlyNBytesProtocol: BinaryProtocol { | ||
static var length: Int { get } | ||
static var length: Int { get } | ||
} | ||
|
||
extension ExactlyNBytesProtocol { | ||
public static func generate() -> Self { | ||
try! Self.init(bytes: Data.random(byteCount: Self.length)) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
apple/Tests/TestCases/Prelude/Bytes/EntropyOfNBytesTests.swift
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import CustomDump | ||
import Foundation | ||
import Sargon | ||
import SargonUniFFI | ||
import XCTest | ||
|
||
final class Entropy16BytesTests: ExactlyNBytesTest<Entropy16Bytes> {} | ||
final class Entropy20BytesTests: ExactlyNBytesTest<Entropy20Bytes> {} | ||
final class Entropy24BytesTests: ExactlyNBytesTest<Entropy24Bytes> {} | ||
final class Entropy28BytesTests: ExactlyNBytesTest<Entropy28Bytes> {} | ||
final class Entropy32BytesTests: ExactlyNBytesTest<Entropy32Bytes> {} |
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
Oops, something went wrong.