bishen28
Issue with ExPublicKey Expublic.load()
Hello guys i am stuck at an issue please help me
![]()
for the biometric authentication in my app, from front-end i am getting public key, signature.
for generating key pair, front end using this library → [https://www.npmjs.com/package/react-native-biometrics?activeTab=readme]
and this algorithms → Algorithmic used by above library
example
like i am getting following public key and signature form front end
public_key : MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsdBu6w2Var6TJHT8TQ1WdDpMu4VzSrDRP8DjY0WI9ddZvQSvjTdUQ9qm3fyZufZpmhPXfjkmg+f/cbJh+m+Zzhf093bcqVVnmEl+an/FTPMaOy2jfYNbxwZDuYCUxJzewGDa74vXCYB2sPgqZikf3UlhI0ZPO8tbdhleGoiQXOcXloAELQ+ebQ6MDBr+QDqNedPW+hLultTClH56v88Tp85PT6HWnPjVQUAWR7QeL+U8mFZOQALBruQvqfB3BwromhTkTB5XtCy1WCGBtzs21CTok4+pWp5QM/E3IUv1B8dtZDqjMIyGhUnM7pFmgL58UYV1unhyMH/cM+ffzlJWIQIDAQAB
Signature : it is encryption of text = "1675256878678"
DQ6vLV4cRAMcCkpT0MTMHPUc8IoMvcckhjY9Fyirq/zX1Ej851g+IojotyPMqSFKbRqrpE3F2OTI717fcAxFRMCFYlcuf1mYjniCJtGTkxTE6m6GNy+ApX5ssUSb3pZajXcLw/YnKvnbiYtsnL0mFgZ27krrp8ZxEf9iDFBJRZW7JVxjaeGqe5jIN64+NODgR+OvMvHPLpNjKIrZleXwQwbOpWE1q9EIhWmApc2bDdUFeaa5RtGOLI9WNkitkhW/Dsk5FNiZOW7oo85IE65cMJ09XTKHCUmYQnhwtdKibKK84koKXELvBat9/aWe+GBdQJQa6mNFfEPnvcmpXDu3tQ==
in the backend i am using elixir ExPublicKey
so the issue that, the public key i am getting from the front end is not getting load as
the public key object type, something like that
{:ok, public_key} = ExPublicKey.loads(public_key)
iex(64)> ExPublicKey.loads(public_key)
{:error, "invalid argument"}
the desired results should be like this
iex(67)> {:ok, public_key} = ExPublicKey.loads(public_key)
{:ok, #ExPublicKey.RSAPublicKey<
fingerprint_sha256= bc
31
a4
6b
51
67
68
b2
63
60
66
73
39
ad
c8
66
1e
07
9d
0c
02
e6
31
23
16
9d
a3
78
4a
04
ef
e8>}
{ok, "1675256878678"} = ExPublicKey.decrypt_public(params.signature, public_key, [])
Help me out here. or any alternative solution in elixir for the above encryption/decryption
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #performance
- #security










Marked As Solved
al2o3cr
I was able to parse that string into an
RSAPublicKeywith:which produces a plausible public key (the exponent is 65537) but with a different fingerprint…
It does validate the supplied signature, though:
Also Liked
jerdew
That looks like a helpful error message at least, look at the
ExPublicKey.RSAPublicKeymodule, perhapsdecode_der?. Also, you’ll probably want toBase.decode64the key you have, because these functions likely want it in a raw binary format.Also might be a useful function here: public_key — OTP 29.0.2 (public_key 1.21.2)
Keep trying and search for examples that do work that you can get a hint from.
Last Post!
bishen28
ok working but one typo here, Thanks
Base.decode64!(signature)