-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(secp256k1): add library to be our dependency for secp256k1 iOS, macos, jvm, android, js #77
Conversation
🦙 MegaLinter status:
|
Descriptor | Linter | Files | Fixed | Errors | Elapsed time |
---|---|---|---|---|---|
✅ ACTION | actionlint | 1 | 0 | 0.07s | |
bash-exec | 4 | 1 | 0.01s | ||
shfmt | 4 | 3 | 0.02s | ||
✅ EDITORCONFIG | editorconfig-checker | 51 | 0 | 0.17s | |
✅ KOTLIN | ktlint | 42 | 0 | 73.5s | |
devskim | yes | 6 | 0.85s | ||
✅ REPOSITORY | dustilock | yes | no | 0.28s | |
✅ REPOSITORY | git_diff | yes | no | 0.02s | |
✅ REPOSITORY | secretlint | yes | no | 2.99s | |
✅ REPOSITORY | syft | yes | no | 0.39s | |
✅ REPOSITORY | trivy | yes | no | 3.99s | |
✅ YAML | prettier | 1 | 0 | 0.46s | |
✅ YAML | v8r | 1 | 0 | 2.41s | |
✅ YAML | yamllint | 1 | 0 | 0.36s |
See detailed report in MegaLinter reports
Set VALIDATE_ALL_CODEBASE: true
in mega-linter.yml to validate all sources, not only the diff
7189fca
to
cdc2fd1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is awesome (mostly over my head), lots of commented code that I think could be removed, and got a couple of questions about naming
@@ -0,0 +1,8 @@ | |||
package io.iohk.atala.prism.apollo.secp256k1 | |||
|
|||
expect class Secp256k1Lib constructor() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wondering why this is named as a "Lib" instead of "KeyPair"? should we adopt this for the others or is there a distinction being implied?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should remove completely KeyPair. It doesn't make much sense.
A PrivateKey should create a Public Key by getPublicKey(): ByteArray
This is more straightforward process.
Secp256k1Lib
is because it uses dependency libs different in each platform to achieve the same. We could call it other way don't mind
// @JsName("fromBigIntegersStrings") | ||
// constructor(x: String, y: String) : this(KMMECCoordinate(BigInteger.parseString(x)), KMMECCoordinate(BigInteger.parseString(y))) | ||
|
||
@OptIn(ExperimentalJsExport::class) | ||
@JsExport | ||
data class KMMECPoint(val x: KMMECCoordinate, val y: KMMECCoordinate) { | ||
@JsName("fromBigIntegersStrings") | ||
constructor(x: String, y: String) : this(KMMECCoordinate(BigInteger.parseString(x)), KMMECCoordinate(BigInteger.parseString(y))) | ||
|
||
@JsName("fromBigIntegers") | ||
constructor(x: BigInteger, y: BigInteger) : this(KMMECCoordinate(x), KMMECCoordinate(y)) | ||
// @JsName("fromBigIntegers") | ||
// constructor(x: ByteArray, y: BigInteger) : this(KMMECCoordinate(x), KMMECCoordinate(y)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we just remove this commented out code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
companion object : KMMECSecp256k1PublicKeyCommonStaticInterface | ||
|
||
fun getEncodedCompressed(): ByteArray { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be getEncoded
to be consistent with the others?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just for EC keys so Secp256k1, the Ed25519 and X25519 I don't think share the same feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I actually deleted it since we raw should be enough. Probably we should just have raw
for all.
// KMMECSecp256k1PublicKey.secp256k1FromBigIntegerCoordinates(tv.point.x.coordinate, tv.point.y.coordinate) | ||
// } | ||
// } | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason not to remove commented code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I will have a look on comments before I merge. I just wanted to see first it actually build on the CI 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
|
||
@OptIn(ExperimentalJsExport::class) | ||
@JsExport | ||
class KMMECSecp256k1PrivateKeyJS { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
guessing I'm missing something, but why have the JS
suffix here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So for any JS exported you will unfortunately have to create a wrapper. Since ByteArray
is not available, you need to create a wrapper that exports BN
or Buffer
instead of ByteArray
and this wrapper converts it.
We can actually name the class in KMM for JS, so although in Kotlin it shows KMMECSecp256k1PrivateKeyJS
we can say to KMM to call this on JS as KMMECSecp256k1PrivateKey
that's the plan.
But bare in mind we still need to test if the API is showing correctly and appealing in JS :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah after our talk I removed the wrappers they are not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to keep it all commented out? Can't we delete the file altogether?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the file
// protected fun MemScope.allocPrivateKey(privkey: ByteArray): secp256k1_pubkey { | ||
// val natPriv = toNat(privkey) | ||
// val pub = alloc<secp256k1_>() | ||
// secp256k1_ec_pubkey_parse( | ||
// ctx, | ||
// pub.ptr, | ||
// natPub, | ||
// pubkey.size.convert() | ||
// ).requireSuccess("secp256k1_ec_pubkey_parse() failed") | ||
// return pub | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to keep this commented? Can be deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can delete it, I just really wanted to have this all passing and ready to merge to be sure that im not missing something :)
94cedff
to
6154217
Compare
…droid, jvm, ios, macos, js add library for secp256k1 in iOS, macOS add libraries for secp256k1 in JVM/Android and removed bouncy castle secp256k1 add new implementation of secp256k1 in common
6154217
to
3e41246
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
add library for secp256k1 in iOS, macOS
add libraries for secp256k1 in JVM/Android and removed bouncy castle secp256k1 add new implementation of secp256k1 in common