<html><head></head><body>
<p>Good point, Chris. However if we copy SHA256 to SHA256InImage,
then #new sent to a concrete subclass would work in your use case,
and we would have SHA256 new as the factory method. Each concrete
subclass would code #new as <code>^ self basicNew initialize;
yourself.</code> Or we could define a #newConcrete method and
refer to that in subclass #new. Heck I believe that
SHA256>>#new could check the receiver class and do the
appropriate instantiation.<br/>
</p>
<p>K, r<br/>
</p>
<div class="moz-cite-prefix">On 7/22/20 2:16 PM, Chris Muller wrote:<br/>
</div>
<blockquote type="cite" cite="mid:CADTxDUjDNB74UFtD7o1Fx=QTH10bj_RxqzF4P-NHYLzUn2mwPg@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<div dir="ltr">Yes, that is one use-case, but another is when you
want an actual SHA256, regardless whether the plugins are
loaded, or not. For its test cases, for example. So, were #new
to become the factory method, it would spoil the API for
THAT use-case.</div>
<br/>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Wed, Jul 22, 2020 at 12:47
PM Robert Withers <<a href="mailto:robert.withers@pm.me" moz-do-not-send="true">robert.withers@pm.me</a>> wrote:<br/>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<p>Hi Levente,</p>
<p>I must admit, after reflection, that I LIKE that <code>SHA256
new</code> may return a different class. Essentially,
the #new method of SHA256, in this scenario, will be the
factory method, instad of HshFunction newSHA256. This
factory method may return a pluginized SHA256 concrete
subclass or itself as default. The reason I like this is
that we would reference the "abstract" class specific to
the hash algorithm as SHA256, exactly the same lexeme. <br/>
<br/>
In our current case, the SHA256 is also a concrete class,
the default when no plugins around. If this duality of
SHA256 being both abstract and concrete, is an issue, we
could copy SHA256 to SHA256InImage and then have a proper
strict abstract class. This is my feeling that opposite of
creating confusion it specifies the Lexeme of this
hashFunction and so clarifies. <br/>
</p>
<p>Newbie: "How do I use SHA256?"</p>
<p>Wise Council: "Code it as <code>SHA256 new</code>. Then
send <code>hashStream:</code> to it.".<br/>
</p>
<p>Jester: "Watch out it is tricky picky. It may return an
instance of a DIFFERENT concrete class....correctly so.</p>
<p>my 2 pennies, <br/>
</p>
<p>Kindly, <br/>
rabbit<br/>
</p>
<div>On 7/21/20 9:56 PM, Levente Uzonyi wrote:<br/>
</div>
<blockquote type="cite">
<pre>Hi Robert,
On Tue, 21 Jul 2020, Robert wrote:
</pre>
<blockquote type="cite">
<pre>Hub Levente,
I like the idea of SHA256 and friends to throw an exception when #new is called directly
SHA256 new.
With a message to call newSHA256.
What do you think?
</pre>
</blockquote>
<pre>I think #new should return an instance of the receiver. That's what
everyone expects when #new is sent to a class, isn't it?
And if #new raised an error, what would #newSHA256 send to create an
instance? #basicNew + #initialize? I don't like that.
Levente
</pre>
<blockquote type="cite">
<pre>Kindly,
Robert
On Tue, Jul 21, 2020 at 14:02, Levente Uzonyi <a href="mailto:leves@caesar.elte.hu" target="_blank" moz-do-not-send="true"><leves@caesar.elte.hu></a> wrote:
Hi Chris,
On Mon, 20 Jul 2020, Chris Muller wrote:
> Hi Levente,
>
> > > HashFunction newSHA256
> > >
> > > instead of
> > >
> > > SHA256 new
> > >
> > > in order to take advantage of Levente's plugin.
> >
> > That is indeed some sort of a change but it only affects those who
> > compiled the SHA256Plugin themselves since that plugin wasn't shipped with
> > the VM.
>
> Ah, you're speaking about legacy code. I really hope we can include your plugin in future VM's. Are Eliot, et al, on board?
The most recent VMs ship with the plugins.
> > I decided against the practice of making #new return an instance of
> > another class than the receiver, as it was with the previous
> > implementation, because that makes it a lot harder for others to
> > understand the code.
>
> Hm. I sort of agree, although I guess Factory is a recognized pattern. To me, the issue is that writing
>
> "SHA256 new"
>
> , is a perfectly intuitive and obvious way to use it, but sticking out like a sore thumb as a subversively-wrong-way to-use-it. It'd be better if it threw an error, and even better than that if it just worked.
>
> I know you care about the quantity of methods in the image (as do I), how about quality? Can SHA256 #new be improved by doing essentially what HashFunction #newSHA256 does, and simply sending some alternative
to new (i.e.,
It's not clear what do you mean by caring about the quantity of methods.
> basicNew initialize) to avoid the recursion?
That would do exactly what I do not want to do: #new would return an
object whose class is not SHA256.
>
> Above, you mentioned you decided against the practice, does that mean you're writing:
>
> SHA256 newSHA256
>
> ? If not, how did you do it?
Use HashFunction's class side #new* methods to create the instances.
HashFunction is a facade and a factory at the same time.
I originally wanted to create a separate class for this role named Hasher,
but HashFunction seemed to work just as well.
Levente
>
> Thanks again for this great work.
>
> - Chris
>
>
> On Sun, Jul 19, 2020 at 9:55 PM Levente Uzonyi <a href="mailto:leves@caesar.elte.hu" target="_blank" moz-do-not-send="true"><leves@caesar.elte.hu></a> wrote:
> Hi Chris,
>
> On Sun, 19 Jul 2020, Chris Muller wrote:
>
> > Hi Robert and Levente,
> >
> > Yes, I *think* so! I'm just now getting up to speed after reading
> > that epic thread between you and Levente (subject line: "SHA512 squeak
> > implementation"). Thanks a ton to both of you, BTW, for this work!
> >
> > After loading
> >
> > ProCrypto-1-1-1
> > and ProCryptoTests-1-1-1,
> >
> > all 205 tests are passing, however, it took me a bit to realize I need to use
> >
> > HashFunction newSHA256
> >
> > instead of
> >
> > SHA256 new
> >
> > in order to take advantage of Levente's plugin. This is great, thanks again!
>
> That is indeed some sort of a change but it only affects those who
> compiled the SHA256Plugin themselves since that plugin wasn't shipped with
> the VM.
> I decided against the practice of making #new return an instance of
> another class than the receiver, as it was with the previous
> implementation, because that makes it a lot harder for others to
> understand the code.
>
> >
> > Quick side question: Is it okay to reuse a SHA256 instance, or should
> > I just create a new one for each and every message to hash?
>
> All subinstances of HashFunction are reusable. The tests
> (see HashFunctionTest) do exactly that.
>
>
> Levente
>
> >
> > Best,
> > Chris
> >
> >
> > On Sat, Jul 18, 2020 at 6:02 AM Robert Withers <a href="mailto:robert.withers@pm.me" target="_blank" moz-do-not-send="true"><robert.withers@pm.me></a> wrote:
> >>
> >> Hey Chris,
> >>
> >> Did this approach fix your issues?
> >>
> >> Kindly,
> >> rabbit
> >>
> >> On 7/13/20 11:46 PM, Robert wrote:
> >>
> >> Hi Chris,
> >>
> >> You should only need to run #3, which will load Registers. Hasher was from before we integrated the code into ProCrypto-1-1-1.
> >>
> >> Installer as project: ‘Cryptography’; install: ‘ProCrypto-1-1-1’.
> >>
> >> Then to load tests run:
> >>
> >> Installer as project: ‘Cryptography’; install: ‘ProCryptoTests-1-1-1’.
> >>
> >> Let us know if any tests fail and we can look into it.
> >>
> >> Kindly,
> >> Robert
> >>
> >>
> >> On Mon, Jul 13, 2020 at 19:52, Chris Muller <a href="mailto:asqueaker@gmail.com" target="_blank" moz-do-not-send="true"><asqueaker@gmail.com></a> wrote:
> >>
> >> Hi Robert, hi Levente,
> >>
> >> I would like to utilize the latest crypto in my next project, would
> >> you help me with the current proper way to configure my image, and my
> >> vm with plugins?
> >>
> >> (image)
> >> In going back through some recent messages on the mailing lists and
> >> instructions on <a href="http://squeaksource.com" target="_blank" moz-do-not-send="true">squeaksource.com</a>, I came across these incantations as
> >> current ways to load the image code:
> >>
> >> 1) Installer ss
> >> project: 'Registers';
> >> install: 'Registers';
> >> project: 'Hasher';
> >> install: 'HAHasher-Core';
> >> install: 'HAHasher-Tests'.
> >>
> >> 2) Installer ss
> >> project: 'Registers';
> >> install: 'Registers';
> >> project: 'Hasher';
> >> install: 'HAHasher'.
> >>
> >> 3) Installer ss project: 'Cryptography'; install: 'ProCrypto-1-1-1'.
> >>
> >> I like these one-click-for-everything scripts for crypto -- it
> >> satisfies the good use-case of development and education, and also
> >> knowing all what's available to Squeak in one glance. My app's build
> >> script can cherry pick what it needs, but any advice on which starting
> >> point above or otherwise is appreciated.
> >>
> >> (vm)
> >> I put the SHA2Plugin.so from Roberts dropbox in the lib directory,
> >> and it shows up as a "Loaded VM Module" in About Squeak. But, three
> >> of the "WithPluginTest"'s are failing. My OS is linux_x64. I don't
> >> know how to build Squeak or plugins from sources, but including it in
> >> the standard precompiled vm would be so pertinent for Squeak today,
> >> IMO. SHA256 is one of the ones I'm going to need, so would be nice to
> >> have it work via plugin. I assume it's a lot faster?
> >>
> >> Thanks,
> >> Chris
> >>
> >> On Tue, Mar 10, 2020 at 3:52 PM Levente Uzonyi <a href="mailto:leves@caesar.elte.hu" target="_blank" moz-do-not-send="true"><leves@caesar.elte.hu></a> wrote:
> >>>
> >>>
> >>> Hi Robert,
> >>>
> >>> With yesterday's help from Eliot and Nicolas, the SHA2Plugin is ready:
> >>> <a href="http://squeaksource.com/Cryptography/CryptographyPlugins-ul.19.mcz" target="_blank" moz-do-not-send="true">http://squeaksource.com/Cryptography/CryptographyPlugins-ul.19.mcz</a>
> >>> The updated version of the image-side code is available in the Hasher
> >>> repository. You can install it with:
> >>>
> >>> Installer ss
> >>> project: 'Registers';
> >>> install: 'Registers';
> >>> project: 'Hasher';
> >>> install: 'HAHasher-Core';
> >>> install: 'HAHasher-Tests'.
> >>>
> >>>
> >>> Levente
> >>>
> >>>
> >>> On Tue, 10 Mar 2020, Levente Uzonyi wrote:
> >>>
> >>>>
> >>>> Hi Robert,
> >>>>
> >>>> Please have a look at:
> >>>> <a href="http://lists.squeakfoundation.org/pipermail/squeak-dev/2020-March/207851.html" target="_blank" moz-do-not-send="true">http://lists.squeakfoundation.org/pipermail/squeak-dev/2020-March/207851.html</a>
> >>>> It answers all your questions.
> >>>>
> >>>>
> >>>> Levente
> >>>>
> >>>> On Tue, 10 Mar 2020, Robert wrote:
> >>>>
> >>>>> Hi Levente,
> >>>>>
> >>>>> I got the SHA2Plugin built and deployed to my Crypto plugins folder. Now I
> >>>> am trying to figure out how to call it from SHA512.
> >>>>>
> >>>>> <a href="https://www.dropbox.com/sh/yhv253rwrhq0q5p/AAB7PKP2KPiGpDnIyule2h_Ia?dl=0" target="_blank" moz-do-not-send="true">https://www.dropbox.com/sh/yhv253rwrhq0q5p/AAB7PKP2KPiGpDnIyule2h_Ia?dl=0</a>
> >>>>>
> >>>>> [plugin] I looked at it and please understand I think the classes you wrote
> >>>> and the framework is really quite nice. I am thrilled we found SHA512! It's
> >>>> impressive that your one plugin can handle a number of hash functions!
> >>>>> Now all I need is to find the code that calls the SHA2Plugin. Levente,
> >>>> would you share that code, please?
> >>>>>
> >>>>> Kindly,
> >>>>> Robert
> >>>>>
> >>>>>
> >>>>
> >>
> >>
> >>
> >
>
>
>
</pre>
</blockquote>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</body></html>