Wolfram Blog
Dariia Porechna

代码的两行防弹加密:在进步发展密码在Wolfram语言manbet万博app

2020年6月16日 -Dariia Porechna,密码学与Blockchain,Wolfram语言发展manbet万博app

代码的两行防弹加密:在进步发展密码在Wolfram语言manbet万博app

Cryptography functionality在里面Wolfram Language一直在增长显著自从它原是released in Version 10.1。在里面最新发布的,we added support for generation and verification of digital signatures for expressions, files and cloud objects; you can encrypt or digitally sign anything—from simple messages to images or code. In order to maintain our users’ security and safety, we base our algorithms onOpenSSL库。尽管OpenSSL的通常要求的经验,使用了大量的,与Wolfram语言融合让它变得更简单。manbet万博app

Encryption

在里面Wolfram Language, encrypting information is as easy as it could possibly be. When usingEncrypt对任何形式的保护数据,你会在输入密码AuthenticationDialogwindow to securely protect your data:

模型= ExampleData [{ “Geometry3D”, “航天飞机”}];
&#10005

模型= ExampleData [{ “Geometry3D”, “航天飞机”}];

ENC =加密
&#10005

ENC =加密[AuthenticationDialog [ “密码”,#password口令&],模型]

认证

这是整个加密过程从开始到结束。只需两个Wolfram语言代码行,您的数据安全manbet万博app与您的密码和行业标准密码派生的防弹关键。

解密将返回你的初始数据,正是因为它是:

解密
&#10005

解密[AuthenticationDialog["Password", #Password &], enc]

从其他编程语言使用OpenSSL成倍变得更复杂。为了在你的C / C ++与OpenSSL的程序执行相同的简单而安全的加密过程,你需要经过耗时的文档阅读。Python和R请勿在本机所有的 - 你会需要选择和配置一个第三方加密包并单独安装OpenSSL的运行OpenSSL的。

Blockchain安全

Elliptic curve keys and digital signatures, newly supported in Version 12.1, allow Wolfram Language users to与blockchains广泛合作。目前,我们支持secp256k1中,同样的椭圆曲线使用比特币Ethereum方舟和无数其他blockchains的。在Wolfram语言的未来版本中,我们计划支持其他的manbet万博app标准曲线,如建议由NIST

生成使用基于椭圆曲线公钥和私钥GenerateAsymmetricKeyPair

keys = GenerateAsymmetricKeyPair
&#10005

keys = GenerateAsymmetricKeyPair["EllipticCurve"]

Once the keys are generated, they are used to create and verify digital signatures:

消息=“时代03 /月/ 2009校长上银行第二救助的边缘”;
&#10005

消息=“时代03 /月/ 2009校长上银行第二救助的边缘”;

签名= GenerateDigitalSignature
&#10005

签名= GenerateDigitalSignature[message, keys["PrivateKey"]]

VerifyDigitalSignature
&#10005

VerifyDigitalSignature [{消息,签名},键[ “公钥”]]

The example message used here comes from块0的比特币blockchain。添加椭圆曲线数字签名支持,很适合在写blockchains。例如,BlockchainTransactionSign使用这些内部到它的准备提交到指定的blockchain之前签订的交易:

arkTX = BlockchainTransaction
&#10005

arkTX = BlockchainTransaction [< |“BlockchainBase”-> {"ARK", "Devnet"}, "Recipient" -> "DLesojAmpcA4jQbJDz5JKQ73k1RervJwfi", "Fee" -> 500000, "Amount" -> 5000000, "TransactionCount" -> 1|>]

BlockchainTransactionSign
&#10005

BlockchainTransactionSign [arkTX,专用密钥[协会[ “类型”  - > “EllipticCurve”, “CurveName”  - > “secp256k1”, “PublicCurvePoint”  - > {104531630294965477234702932341314658269653137311559363531300075335186 \ 469390907,10640048778270064292136312118618106290978266224313779661960878181 \ 1804637106603}, “PrivateMultiplier”  - > 462334184832703249382743573975806080334034824670864224636440700338 \ 84386623284,“压缩”  - >真, “PublicByteArray”  - >的ByteArray [{3,231,26,206,92,80,143,224,194,24,207,131,164,219,131,21,1,243,142,42,166,89,103,207,196,217,90,115,24,134,168,138,59}], “PrivateByteArray”  - >的ByteArray [{102,55,48,如图2所示,13,244,228,151,216,47,103,217,53,81,190,188,237,119,237,194,如图2所示,245,72,113,217,50,144,69,50,10,255,52}]]]]

您还可以使用数字签名来签署并验证图片要么any arbitrary Wolfram Language expression:

GenerateDigitalSignature
&#10005

GenerateDigitalSignature[\!\( \*SubsuperscriptBox[\(\[Integral]\), \(0\), \(\[Infinity]\)]\(Log[ x]\ Exp[\(- \*SuperscriptBox[\(x\), \(2\)]\)] \[DifferentialD]x\)\), PrivateKey[ Association[ "Type" -> "EllipticCurve", "CurveName" -> "secp256k1", "PublicCurvePoint" -> { 104531630294965477234702932341314658269653137311559363531300075335\ 186469390907, 10640048778270064292136312118618106290978266224313779661960878181\ 1804637106603}, "PrivateMultiplier" -> 46233418483270324938274357397580608033403482\ 467086422463644070033884386623284, "Compressed" -> True, "PublicByteArray" -> ByteArray[{3, 231, 26, 206, 92, 80, 143, 224, 194, 24, 207, 131, 164, 219, 131, 21, 1, 243, 142, 42, 166, 89, 103, 207, 196, 217, 90, 115, 24, 134, 168, 138, 59}], "PrivateByteArray" -> ByteArray[{102, 55, 48, 2, 13, 244, 228, 151, 216, 47, 103, 217, 53, 81, 190, 188, 237, 119, 237, 194, 2, 245, 72, 113, 217, 50, 144, 69, 50, 10, 255, 52}]]]]

“Know Your Keys”

We’ve greatly expanded user flexibility and freedom with public and private key objects. In Version 12.1,PrivateKey公钥can compute all of the necessary parts of a key from an arbitrary value.

Access the public key of any blockchain transaction sender on Bitcoin, Ethereum or ARK:

BlockchainTransactionData
&#10005

BlockchainTransactionData [ “a93bfdff6679bc38cfdcd16cc38e34513fa2ee97186864e22cac5723864cde13”, “SenderPublicKey”,BlockchainBase  - > “复仇”]

通过粘贴必要的值(例如,作为一个十六进制字符串)使用所产生的钨生态系统外部自己的钥匙。manbet万博appPrivateKey公钥做这项工作的其余部分:

私人=专用密钥
&#10005

私人=专用密钥[<| “类型”  - > “EllipticCurve”, “PrivateHexString”  - > “E9873D79C6D87DC0FB6A5778633389F4453213303DA61F20BD67FC233AA33262” |>]

公共=公钥
&#10005

公共=公钥[私人]

为了实验的私钥和公钥的数学特性,你可以指定一个任意值:

PrivateKey
&#10005

PrivateKey[<|"Type" -> "EllipticCurve", "PrivateMultiplier" -> 100|>]

发明了自己的私人密钥时,一定要加倍小心。如果你需要一个实际使用,最好使用内置的密码安全生成一对random number generationwithGenerateAsymmetricKeyPair

一般来说,人类努力创造长期,随机和强密码,通常选择了短密码容易重用,使他们脆弱,更容易破解。GenerateDerivedKey中,密钥推导函数(在密码散列和认证中使用),加强关键:

GenerateDerivedKey
&#10005

GenerateDerivedKey["password"]

处理文件

We’ve createdEncryptFileto keep sensitive data private and only accessible by those who are authorized to do so. This enables research, computed results, Wolfram Language code or any other sensitive information to be encrypted and stored safely.

Encrypta file containing an image, writing the result to a new file:

EncryptFile
&#10005

EncryptFile [AuthenticationDialog [ “密码”,#password口令&]的FindFile [ “ExampleData / rose.gif”], “codedrose.mx”]

采用DecryptFile得到加密文件回来,再次把结果在一个新的文件:

DecryptFile
&#10005

DecryptFile[ AuthenticationDialog[ "Password", #Password &], "codedrose.mx", "rose.gif"]

Import解密文件:

Import
&#10005

Import["rose.gif"]

此外,我们还添加了GenerateFileSignatureVerifyFileSignature对于任何形式的数字签名和验证文件(甚至是云对象!)。这两个函数使用RSA或椭圆曲线的安全性:

对象= CloudPut
&#10005

对象= CloudPut [123, “测试”];

keys = GenerateAsymmetricKeyPair
&#10005

键= GenerateAsymmetricKeyPair [ “RSA”];

签名= GenerateFileSignature
&#10005

签名= GenerateFileSignature [对象,键[ “专用密钥”]]

VerifyFileSignature
&#10005

VerifyFileSignature[{object, signature}, keys["PublicKey"]]

总是有更多

更充分地利用加密技术在Wolfram语言manbet万博app从我们的文档中心观看直播视频中,我讲解了最新功能in more detail. We are constantly expanding and improving upon cryptography functionality for future versions. If you have ideas on what we should prioritize for this feature, let us know in the comments.


本产品包括由OpenSSL Project为OpenSSL工具包的软件。本产品包括由Eric Young编写的加密软件

可以完全访问最新的Wolfram语言的功能与manbet万博app数学12.1要么Wolfram|One审判。

发表评论

没意见




发表评论