The current API seems to be very verbose at the moment as it seems to just be the generated protobufs. I in particular am using Kotlin so I can work around it, but it's not that great either:
val keyAttributes =PsaKeyAttributes.KeyAttributes.newBuilder().apply {
keyType =PsaKeyAttributes.KeyType.newBuilder().apply {
eccKeyPair =PsaKeyAttributes.KeyType.EccKeyPair.newBuilder().apply {
curveFamily =PsaKeyAttributes.KeyType.EccFamily.SECP_R1
}.build()
}.build()
keyPolicy =PsaKeyAttributes.KeyPolicy.newBuilder().apply {
keyUsageFlags =PsaKeyAttributes.UsageFlags.newBuilder().apply {
signHash =true
signMessage =true
verifyHash =true
verifyMessage =true
}.build()
keyAlgorithm =PsaAlgorithm.Algorithm.newBuilder().apply {
hash =PsaAlgorithm.Algorithm.Hash.SHA_256
asymmetricSignature =PsaAlgorithm.Algorithm.AsymmetricSignature.newBuilder().apply {
ecdsa =PsaAlgorithm.Algorithm.AsymmetricSignature.Ecdsa.newBuilder().apply {
hashAlg =PsaAlgorithm.Algorithm.AsymmetricSignature.SignHash.newBuilder().apply {
specific =PsaAlgorithm.Algorithm.Hash.SHA_256
}.build()
}.build()
}.build()
}.build()
}.build()
}.build()A few options would include:
- Generating optional kotlin protobuf extensions (though this only helps kotlin users)
- Adding some helpful constants (like I believe the rust client has)
- Add new, more usable classes that are more adapted to the JVM with easier-to-use builders and such
The current API seems to be very verbose at the moment as it seems to just be the generated protobufs. I in particular am using Kotlin so I can work around it, but it's not that great either:
A few options would include: