From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 1651 invoked from network); 23 Nov 2022 23:56:08 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 23 Nov 2022 23:56:08 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1669247768; b=o5LeelYuWk3saodnDTpjt1B7DnvBQqzesCOkDzLVCknAQCgJvjX6JdBW1p87oqPVBuBRA2fnhu FbgmE52qzXSGbm2uyAbIpbEU56NpmWmna0WdDZ1KuH8Zs57PWR/qOKsa8yQnLu/2h1XfvjkTJr FltyyAXsQMdsTIPrzW8X/5/jm1RlyOvTBa/OfNtQWJmzS93gXH29SMWz/UlFNEgTGQXKfAcoD4 OKUt+HPpU1Ntq06S6wStXJmsTNzIPdA6RynhVIoFeArE6zkPwt6EV3dL926egZlYAvo7BHUM6J q8dLdksvjLTYyrn2YJM3xLzok23561wYGOEXw31gg6Nf8w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (out4-smtp.messagingengine.com) smtp.remote-ip=66.111.4.28; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1669247768; bh=an1zkzJKq/5oWVldZrrJp4aX8Ag3Pp8fkaX5tSDY0UU=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Subject:Cc:To:From: Date:References:In-Reply-To:Message-ID:MIME-Version:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=AoDfvdY+uO5UE+zbp4YbZrT3UlK5tcPV2M0NJYaRRR7ax1Bhb2f2hgv9T/IWFaB6Oe0fdYgqDo XgOKXVggm+Lixf3pR1Q/92adQRzwud2IGUjGu1jOE5oCXUbfKoUbiLXNus66RI2ThKpz3Vp8yn USsdhCdLUKo2T+1DV/al5EzOhjo6onuhZnKIJ988VrifhDZdEV/uCYR6gE8pqsYoaY7uNLYzkt hlelhMhzzpVdirr3Jeh15WV6gugjJoPW63zXsyMz+7An3eS+FRW330vcAngltRXP+F0OCQC02j 2rFfIm8o9Gp8ZtIYurxAXiEFTI5NgKPBJttYhhaze9jLkQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:Subject:Cc:To:From:Date:References:In-Reply-To:Message-Id: Mime-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=Z2zQPgYZaWHCJmjquqR5qOK4iyIfJrkBSgoV4vIUv54=; b=jXO5HLZLDkS7TWWMudhhCp+LNT tcbGywGGKb6MG7+VEurc5YOP2fgK3DqWlptrT2mxkV+8u9vFpC+1Tw7UiUi61sObQRiV5q50CDscu k8Rx9g/L4m+MnsB8Rh3xZkbINEzHgHZldkG5lgln0eyHHuNzlw/4qrKREju2dJH9ptzIQWEZiA9wc a0w3KgAvsdeaEx/ysjESWPhpYasAMrntQ9JjEVPUawATvIuFS39CkRsmT2ELI0xMU9ooQzvbUJtEh Owc9EkPEGUcqdphI04dqJHKWFYZlkW+IS7wOiuGXG9Vp7fxLI+TKjS38TVZ1EZeb5vVblf1YeS8hp mqVZKkyw==; Received: by zero.zsh.org with local id 1oxzb5-0009yb-TM; Wed, 23 Nov 2022 23:56:07 +0000 Authentication-Results: zsh.org; iprev=pass (out4-smtp.messagingengine.com) smtp.remote-ip=66.111.4.28; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from out4-smtp.messagingengine.com ([66.111.4.28]:44305) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1oxzal-0009bB-Aj; Wed, 23 Nov 2022 23:55:53 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id F2CAD5C018A; Wed, 23 Nov 2022 18:55:45 -0500 (EST) Received: from imap46 ([10.202.2.96]) by compute2.internal (MEProxy); Wed, 23 Nov 2022 18:55:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; t=1669247745; x=1669334145; bh=Z2zQPgYZaW HCJmjquqR5qOK4iyIfJrkBSgoV4vIUv54=; b=vq0GBdWD16zdZyD4TxG7Rod//6 qYu7+gnJ0nGjKPY57BrIaDhrIn0AUwCDhAMmC+Vim9bOyCznhXOaNP5lxkb8+qZw v7k1hHW7bQxSekdzYcpQa4NJh42zGjCChKWj9oFwt77fYs1g6PO8SogzfUG9t09z jU6Ngne4OdYQQ2LzpjEVxYn+yOA5tbsSlQn4IyRHqwt5DZqmZLTTHRZNWbje9rwF d050ryNaPvh/OIRFOdnErRolgXQa74lvko5v0ofTfrRry/zAQzdNmZ7YC0LYF/II Q6AHxvaN3SnnfE5C6FFUmhKt5iPxqu1RM0Ifv3CwAlqaTV0oVdJ5qFlxx4Uw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1669247745; x= 1669334145; bh=Z2zQPgYZaWHCJmjquqR5qOK4iyIfJrkBSgoV4vIUv54=; b=K RXX/OSNQ24IsO5yUftOHR3fF6OSTpLB6s1rXtB6rEGu4NrhAZysBSkfK/t+PyNca FEmqaAj5n3Fq3/dYaEQ3V+Mc5lAmmSpItuMebLNZNont9Uz4E+PfAbsDpZcsZEQJ r+OyEe4BRP3kxMk9qAmG6MPmxJalXMwRowQMZc3mvDF49bduGzbGjKgmTjDSA508 9RviG2onSOv1E3w/8Gqh+Ssx7ZoYwXuEJGjooF9zv2s1rBjL7qWHFKl86zo87aOD f4aXax4QCUIJ28HXO7oypVy5Rx7C+8U6ruxtaDlv0kL2kaN/Agt8MlT/w2kgYDq8 lcZLhTxBs5+WCLqV7e1IA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedriedvgddugecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvfevufgtgfesth hqredtreerjeenucfhrhhomhepfdffrghnihgvlhcuufhhrghhrghffdcuoegurdhssegu rghnihgvlhdrshhhrghhrghfrdhnrghmvgeqnecuggftrfgrthhtvghrnhepffdvheeutd dugeejledtjeethfehueeukeeijeehueduiefgfeevjeeiieeifedvnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepugdrshesuggrnhhivghlrd hshhgrhhgrfhdrnhgrmhgv X-ME-Proxy: Feedback-ID: i425e4195:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id C19C82A20080; Wed, 23 Nov 2022 18:55:45 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-1115-g8b801eadce-fm-20221102.001-g8b801ead Mime-Version: 1.0 Message-Id: In-Reply-To: <869f6d65-15d2-477f-b78b-02427a0c1395@app.fastmail.com> References: <1b2cafe6-b4b5-c59a-11f3-4dbc1e99e2bc@zentaur.org> <6275a5ac-3a47-f591-7b3c-380ec4fed5ac@zentaur.org> <3423b634-a7c3-9efc-92cd-b9b995ac1c27@zentaur.org> <30a7e749-7f30-ecae-6479-a345b1682e7f@zentaur.org> <2df1001e-69a6-9785-70a6-8416fdcffd8d@zentaur.org> <0a07afaf-1194-6752-8133-8aa6b689724d@zentaur.org> <20221123203329.GP27622@tarpaulin.shahaf.local2> <869f6d65-15d2-477f-b78b-02427a0c1395@app.fastmail.com> Date: Wed, 23 Nov 2022 23:54:06 +0000 From: "Daniel Shahaf" To: "Zsh hackers list" Cc: "Clinton Bunch" Subject: Re: [PATCH] zsh/random module [UPDATED] Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Seq: 51052 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: dana wrote on Wed, 23 Nov 2022 21:42 +00:00: > On Wed 23 Nov 2022, at 13:46, Daniel Shahaf wrote: >> + Why should -c default to 8 in the "random bytes" case? Why >> shouldn't it default to some other value, or even be required to = be >> specified explicitly by the user? ... >> - Why should -c's default depend on anything at all? You mentioned >> downthread you consider making -c1 the default in all cases; that'd= be >> better. > > The defaults with this API are kind of weird, because if you make them > dependent on the format (e.g. 8 for hex and 1 for everything else) it'= s kind > of arbitrary, but if you keep them all the same (e.g. 1 or 8 for every= thing) > they aren't generally useful =E2=80=94 i think it's safe to assume tha= t 'i would like > exactly 1 random hex digit' is not going to be the most common use case > Well, agreed on that last sentence, but note that =C2=AB-c 1=C2=BB in th= e patch means one byte, not one nibble. > Requiring the user to explicitly specify it would address that, though= you > could say then that it goes the other way, e.g. again it's probably sa= fe to > assume that 90% of the time you're only going to want one integer valu= e, and > making people write that out every time, whilst expected in a lower-le= vel API > like a C function, is maybe annoying in a convenience shell built-in > But 1 /is/ the default for integer mode, and I don't think anyone proposed to change that? Rather, it was proposed to change the default for bytes mode from 4 bytes (8 nibbles) to 1 byte. Do you reckon reques= ting 4 bytes should be the default for that mode, as opposed to, say, 1, 2, 8, or 64 = bytes? > But annoying is probably better than confusing, if those are the optio= ns > Heh :) > On Wed 23 Nov 2022, at 13:46, Daniel Shahaf wrote: >> Oh, and bump that 16 to something 3 or 4 times as big, because a 1/65= 536 >> chance isn't really enough in a world where automated builds (CI, >> distros' QA, etc.) is a thing. > > I feel like it should be very nearly impossible for a test to fail jus= t for > randomness reasons. Maybe it's over-kill but in my draft reply to the = patch i > was going to suggest something like this: > > () { > repeat $(( 10 ** 5 )); do > getrandom -L4 -U5 -c64 -a tmpa > [[ $tmpa[(r)5] =3D=3D 5 ]] && return 0 > done > return 1 > } > No maybe about it :) With these parameters, the probability of a false positive is 2 to the power of minus the overall number of iterations, i.e., 2**(-6.4 million), which is 1/[a number that has 1.9M decimal digits]. To be clear, it's not 1/1.9M, which is about the probability of a random Londoner being at 10 Downing Street right now. It's 1/[10 ** 1.9M], which is about the probability of correctly guessing the genders of all Londoners. If you converted the entire Earth's mass to CPUs and ran =C2=ABgetrandom= -L4 -U5 -c64=C2=BB on it repeatedly until Sol died, and the CPUs all operate= d at 4GHz, and there were no bugs in anything, the chance of getting a single run to not return a 5 would still be something like a billion to one (give or take several zeroes depending on CPU mass, the argument to -c, and so on). That's why in practice, if a single -c64 call ever doesn't return a 5, it's safe to assume there's a bug. Conversely, if you actually retain those 6.4 million iterations, what's the probability that the outer loop will return 0 on the first iteration and then a gamma ray will flip that to 0?