soundart / perl6-tweetnacl Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
Hi, I saw the note in the README requesting some feedback. I had some golang code that used these primitives to do SecretBox encryption/decryption so I wrote a bit of P6 code to see how it compared.
I was able to interoperate with the golang code fairly easily so it is great to know that it is compatible with other implementations.
Having written some P6 nativecall-based code in the past, here's some design suggestions based on that. My general philosophy is that I want to use nativecall-based modules to hide the details of C behind things that make more sense from P6. The same thought applies to ctypes in Python or XS in Perl 5 or any other bindings around C language libraries.
To this point, modules should avoid exporting the C functions. So in SecretKey.pm6
, you would avoid marking crypto_secretbox_open_int
as is export
. If you do think that consumers of your modules may want to import and use these directly, consider putting them all in a Raw.pm
file, similar to how GTK::Simple
does it.
Along these lines, avoid requiring CArray
and other NativeCall types as input parameters. I've found that functions taking CArray
can be represented by the Blob
type, since Blob also permits Buf
and utf8
, both are fairly common. You can take advantage of some other modules to help here, see the modules in the NativeHelpers::
namespace: http://modules.perl6.org/search/?q=nativehelpers
You may also consider using subtypes of Blob: subset KeyData of Blob where *.elems == 32
. Then you can use this as a type parameter.
I would also suggest unifiying the return types of the two encrypt
multi methods, since it seems weird to have them return different types depending on if you provide a nonce or not. If you do want different return types, I suggest document this.
Aside from this, I found the code reliable so far, so that's excellent. Thanks for putting this out here so other people can use it, I really appreciate it.
Not sure if you are still actively interested in Perl 6 and/or this code, but thought I would pass along the feedback in hopes that it helps. Let me know if you want any more information or examples and I'll see what I can do.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.