问题标签 [pynacl]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
280 浏览

python - 基于alpine的docker镜像内robotframework-sshlibrary的安装

我正在尝试使用基于 alpine 的 robotsframework-sshlibrary 构建 docker 映像,但收到一条神秘的错误消息:

安装 PyNaCl 时出现错误,这是 sshlibrary 的依赖项。该库在构建这些依赖项期间使用了一些本机依赖项和错误引发。

我使用以下 Dockerfile:

然后我运行:

但是当我从命令行手动安装它时,一切都很好。

不确定问题来自 docker 或 pynacl 大楼。错误似乎与访问权限有关,但我在容器内的命令是使用默认用户 root 运行的。我在我的 Dockerfile 中添加了一些 ls -la 和 id 来检查访问权限,一切看起来都不错。

我的主机系统是带有 Linux 4.19.0-8-amd64 的 debian 10.7,docker 是 20.10.2

0 投票
0 回答
352 浏览

pip - PyNaCl 不想在 PyGithub 安装期间安装(轮子构建未完成)

我已经尝试过:

  • 以 sudo 运行命令(如您所见)
  • 降级点子
  • 安装 make 和其他 build-essential
  • 单独安装 pynacl
  • 在不使用 PEP 517 的情况下安装它(它没有安装,只是输出一个需要 PEP 517 的错误)

Linux Ubuntu 18.04(服务器)Python3 版本是 3.6.9 pip 是最新版本(如果我是正确的,是 21.1)我正在通过 Webmin 1.973 做所有事情

我使用命令“sudo pip3 install pynacl --log”重新运行日志链接:登录 pastebin.pl

0 投票
0 回答
109 浏览

python - Finding corresponding PyNaCL functions in libsodium (C#)

I am using a python rest server (which I found here: https://github.com/xxblx/tornado-app-template) that supports access tokens and lets a client sign the access tokens. The repository contains a python client that creates a SigningKey on the client side. The provided code shows how to create the required keys and hashes required to create a user that is later able to sign tokens.

I want to write a C# client that can generate a SigningKey and is capable of signing the tokens in the same way. I am using libsodium 1.0.16 for my client and I am having trouble creating an equivalent keypair, not to mention finding the corresponding function for creating the password_hash or the key in the above code. I am not even sure which functions to use for the key creation. From my small understanding of crypto, I assume that it should be possible. Any help regarding finding the correct libsodium function for the above used nacl functions (nacl.hash.blake2b, nacl.secret.SecretBox(key), nacl.pwhash.argon2i.kdf(...), etc) or a hint for creating an equivalent SigningKey would be great.

My approach in C# using libsodium to create this public and secret key looks like this:

Is this a good start?

0 投票
1 回答
225 浏览

python - 在 tweet-nacl (javascript) 中加密并在 python 中解密

这个问题与这里现有的问题相反: Encrypt in python 3.7 and decode in NODEJS 12

我更愿意在 python 上使用与tweet-nacl完全相同的东西,但该项目说它很旧,不推荐使用https://github.com/warner/python-tweetnacl。他们推荐的替代品是https://github.com/pyca/pynacl:但是那个是libsodium的接口而不是tweet-nacl,并且没有关于如何实现解密的明确文档。

这是JS加密:

(工作的) tweet-nacl javascript 解密代码是:

我的问题是,因为pynacl他们没有显示任何使用ephemPubKey进行解密的示例。我能找到的例子如下:

有没有人能够将 tweet-nacl Javascript 生成的加密成功解密成 python?

0 投票
4 回答
211 浏览

macos - 无法在 macOS 上安装 erdpy - pynacl 的构建轮失败

我正在尝试erdpy按照官方指南在 macOS 上安装,我成功地下载erdpy-up了,当我运行它时,我收到以下错误:

在那之前,我看到:

尝试libsodium使用 brew 安装,但erdpy安装仍然失败。

还有另一种安装/构建它的方法吗?

0 投票
2 回答
54 浏览

discord.py - 我正在尝试编写一个不和谐的音乐机器人并遇到了这个问题

我的问题是包裹是标签之一

在此处输入图像描述

main.py 代码

0 投票
0 回答
33 浏览

python-3.x - 签署已经在 pynacl 中散列的有效负载

我正在将应用程序从 Python cryptography.io 库切换到 pynacl。

应用程序当前计算数据的摘要,然后让加密库对摘要进行签名。

但是 pynacl 的签名代码总是需要将完整的数据传递给sign方法,而以代码的结构方式很难做到这一点(并且在某些情况下可能是不可能的,例如无法读入内存的非常大的文件)。

所以这两个问题是:

  1. 有没有办法简单地将我的数据的预先计算的摘要sign传递给一个带有 pynacl 的函数并让它签名?
  2. 将我的数据摘要作为 , 而不是直接传递数据会不会存在安全问题message?(如果是这样 - 以及与 EC25518 一起使用的算法或哈希大小的建议或限制?)
0 投票
1 回答
220 浏览

solana - 如何使用 Python (PyNaCl) 验证由 Solana 钱包适配器 (javascript) 签名的消息

我使用Solana 的钱包适配器示例签署了一条消息:

  • 使用的公钥:DKpHyR1WjWE23E3xizPUhefZKmpMrMXNBVfoxQ7WXCRR
  • 留言签名:hello
  • 收到签名:3EWDdtU1w8pWkr6fg8faJvKn1wBZmNjgf5kUx4Pn5gw4HeBPYVDm7cTHNqpRVMami6yX36jdaeZacv9GXR19Jzye

但我无法使用 Python 3.9 和PyNaClSolana-py验证签名消息。我尝试了以下方法:

但验证返回:nacl.exceptions.BadSignatureError: Signature was forged or corrupt.

有人知道出了什么问题吗?会不会是编码问题?似乎 JS 使用以下字节类型:

在python中:

我需要在 Python 上使用一些不同的编码吗?

0 投票
1 回答
32 浏览

python - PyNaCl 库需要,已导入,但仍需要

我最近开始在 Python 上制作 Discord 机器人,我想创建一个音乐播放选项,所以我使用了需要库“PyNaCl”的函数“connect()”,所以我安装了该库并将其导入我的Python 程序,但是当我调用 connect() 函数时,出现以下错误:

但是我确实导入了 nacl 库。如何使用 connect() 函数?

顺便说一下,这是我的节目音乐部分:

谢谢阅读,

三板。

0 投票
1 回答
13 浏览

python - 如何使用 Python 将 nacl SigningKey 公钥和私钥保存为纯文本?

我一定在nacl 文档中遗漏了一些东西。如何以纯文本格式保存私钥和公钥?可用的编码器有 Raw(二进制?)、Hex、Base16/32/64 和 URLSafeBase64Encoder。

我以为我会使用该base64库来转换 Base64 编码的密钥。

例子:

结果:字节对象

试过:

  • 这里的Decoding Strings with Python教程,以及各种变体。
  • 它们都不会导致纯文本版本的SigningKey
  • 我正在寻找-----BEGIN OPENSSH PRIVATE KEY-----纯文本中的等
  • 如何强制该b64decode功能显示纯文本?